高德地图POI搜索,附近地图搜索,类似附近的人搜索

news/2024/7/7 18:28:59


效果图:




首先导入道德地图的SDK,导入步骤不在这里介绍

2:包含头文件:

[objc] view plaincopy
在CODE上查看代码片派生到我的代码片
  1. #import <AMapSearchKit/AMapSearchAPI.h>  
3:代码

[javascript] view plaincopy
在CODE上查看代码片派生到我的代码片
  1. @property(nonatomic,strong)AMapSearchAPI *mapSearch;  
  2. @property(nonatomic,strong)AMapPlaceSearchRequest *poiRequest;  



[objc] view plaincopy
在CODE上查看代码片派生到我的代码片
  1. -(void)searchAroundLocal:(AMapGeoPoint *)geoPoint  
  2. {  
  3.   
  4.     if ( !self.mapSearch) {  
  5.         self.mapSearch=[[AMapSearchAPI alloc] initWithSearchKey:(NSString *)APIKey Delegate:self];  
  6.     }  
  7.       
  8.     self.poiRequest = [[AMapPlaceSearchRequest alloc] init];  
  9.       
  10.       
  11.     AMapGeoPoint *searchPoint =[AMapGeoPoint locationWithLatitude:  
  12.                                 22.540000  
  13.                                                         longitude:113.900000];  
  14.       
  15.     self.poiRequest.searchType = AMapSearchType_PlaceAround;//搜索的类型为周边搜索  
  16. //    self.poiRequest.types =AMapRequireGroupbuy;                 //搜索的内容  
  17.     self.poiRequest.offset = 120;                //每页搜索的信息个数  
  18.     self.poiRequest.location = searchPoint;      //搜索的中心点  
  19.     self.poiRequest.keywords=searchKeyString;  
  20.     self.poiRequest.radius = 5000;               //搜索半径  
  21.     self.poiRequest.sortrule = 0;                //结果以远近排序  
  22.     //发起POI搜索  
  23.     [self.mapSearch AMapPlaceSearch:self.poiRequest];//发起请求搜索  
  24. }  
  25. #pragma mark - AMapSearchDelegate  
  26. /* POI 搜索回调. */  
  27. - (void)onPlaceSearchDone:(AMapPlaceSearchRequest *)request response:(AMapPlaceSearchResponse *)response  
  28. {  
  29.     NSLog(@"inset=%@",TABLEHEAD);  
  30.     for (AMapPOI *p in response.pois) {  
  31.         if (p) {  
  32.               
  33.             [locArr addObject:p];  
  34.               
  35.         }  
  36.           
  37.     }  
  38.     [locArr insertObject:TABLEHEAD atIndex:0];  
  39.     [self.view endEditing:YES];  
  40.     [self.tableView reloadData];  
  41. }  
  42.   
  43. - (void)searchRequest:(id)request didFailWithError:(NSError *)error  
  44. {  
  45.     NSLog(@"====出错信息:%@",error);  
  46. }  
  47. - (void)search:(id)searchRequest error:(NSString *)errInfo __attribute__ ((deprecated("use -search:didFailWithError instead.")))  
  48. {  
  49.   NSLog(@"====出错信息:%@",errInfo);  
  50. }  

其中

self.poiRequest.keywords=searchKeyString;


http://lihuaxi.xjx100.cn/news/235409.html

相关文章

20位程序员关于求职的疑问,以及我给出的参考答案

作者&#xff1a;陆小凤首发&#xff1a;公众号【程序员江湖】阅读本文大概需要 6 分钟。前几天发了一条朋友圈对于求职小伙伴们提出的问题&#xff0c;我进行了收集整理&#xff0c;统一反馈。也许这20个问题也是你们遇到的问题&#xff0c;所以趁着年前赶紧把它发出来。以下2…

开博啦!

2007年10月10日&#xff0c;终于在博客园安家啦&#xff0c;希望以后和大家分享一些我的知识和经验&#xff0c;交到志同道合的朋友。我的奋斗目标是成为博客园里的高手之一。 希望多多棒场。 转载于:https://www.cnblogs.com/sandy/archive/2007/10/10/920110.html

Swift - AppDelegate.swift类中默认方法的介绍

项目创建后&#xff0c;AppDelegate类中默认带有如下几个方法&#xff0c;具体功能如下&#xff1a; 1&#xff0c;应用程序第一次运行时执行这个方法只有在App第一次运行的时候被执行过一次&#xff0c;每次App从后台激活时都不会再执行该方法。&#xff08;注&#xff1a;所有…

【转载】gdi+ 内存泄漏

【转载】http://issf.blog.163.com/blog/static/1941290822009111894413472/ 最近用GDI实现了几个自定义控件&#xff0c;但是发现存在内存泄露问题 BOOL CGdiplusBugDlg::OnEraseBkgnd(CDC* pDC) {Image* pImage Image::FromFile(L"E:\\bac.bmp");Graphics g(pDC-&…

三、数据类型

一、有序无序可变不可变#1、有序&#xff1a;但凡有索引的数据都是有序的 #2、可变不可变 #可变类型&#xff1a;在值变了的情况下&#xff0c;id不变&#xff0c;证明在改原值 #不可变类型&#xff1a;在值变了的情况下&#xff0c;id也跟着变&#xff0c;证明不是在改原值二、…

iOS支付宝(Alipay)接入详细流程,比微信支付更简单,项目实战中的问题分析

最近在项目中接入了微信支付和支付宝支付&#xff0c;总的来说没有那么坑&#xff0c;很多人都说文档不全什么的&#xff0c;确实没有面面 俱到&#xff0c;但是认真一步一步测试下还是妥妥的&#xff0c;再配合懂得后台&#xff0c;效率也是很高的&#xff0c;看了这篇文章&a…

飞凌OK6410开发板移植u-boot官方最新版u-boot-2012.10.tar.bz2

Part0 准备知识 0.1 关键参数说明 0.1.1 开发板说明 OK6410是飞凌公司发布的一款开发板&#xff0c;当前有2个版本&#xff0c;OK6410-A和OK6410-B&#xff0c;我当前使用的是前者&#xff1b;前者也经历过升级&#xff0c;所以有128M ram的和较新的256内存的版本&#xff0c;n…

高德地图关键字搜索oc版

.h文件 // MapSearchViewController.h // JMT // // Created by walker on 16/10/11. // Copyright © 2016年 BOOTCAMP. All rights reserved. // #import <UIKit/UIKit.h> #import <AMapNaviKit/MaMapKit.h> #import <AMapSearchKit/AMapSearchKit.h&…