描述:
求大神解答:百度地图的poi如何调用,比如我想在程序里面写死“北京”“餐厅”,然后在客户端搜索“海底捞”,搜索结果都是餐厅这一类中的。而不是在北京这个范围内搜索“海底捞”,结果中不仅有餐厅,还有超市等等,这样就没意义了。
解决方案1:
我用C# 写过POI采集软件,楼主可以互相交流下啊。 我QQ:1175441108
解决方案2:高德API这边,搜索类型比较全,推荐你一下。不光有餐厅,还有很多小门类http://api.amap.com/Public/down/AMap_Api_Table.zip 可以下载看看!
// 第一个参数表示搜索字符串,第二个参数表示POI搜索类型
// 第三个参数表示POI搜索区域(空字符串代表全国)
query = new PoiSearch.Query(keyWord, "餐厅", cityCode);
query.setPageSize(10);// 设置每页最多返回多少条poiitem
query.setPageNum(currentPage);//设置查第一页
PoiSearch poiSearch = new PoiSearch(this,query);
poiSearch.setBound(new SearchBound(new LatLonPoint(locationMarker.getPosition().latitude,
locationMarker.getPosition().longitude), 1000));
poiSearch.setOnPoiSearchListener(this);
poiSearch.searchPoiAsyn();
搜索前直接硬给他增加到前面呗
解决方案4:随手写一个DEMO:
- (void)viewDidLoad
{
[super viewDidLoad];
_search = [[BMKSearch alloc]init];
_search.delegate = self;
// 设置地图级别
[_mapView setZoomLevel:13];
_mapView.isSelectedAnnotationViewFront = YES;
//发起POI检索
BOOL flag = [_search poiSearchInCity:@"武汉" withKey:@"武汉协和医院" pageIndex:0];
if(flag){
NSLog(@"success!");
}else{
NSLog(@"error!");
}
}
- (void)onGetPoiResult:(NSArray*)poiResultList searchType:(int)type errorCode:(int)error
{
// 清楚屏幕中所有的annotation
NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
[_mapView removeAnnotations:array];
BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
// 30.5907940162,114.2823383453
CLLocationCoordinate2D coor;
coor.latitude = 30.5907940162;
coor.longitude = 114.2823383453;
item.coordinate = coor;
item.title = @"武汉协和医院";
[_mapView addAnnotation:item];
_mapView.centerCoordinate = coor;
}
/**
*根据anntation生成对应的View
*@param mapView 地图View
*@param annotation 指定的标注
*@return 生成的标注View
*/
- (BMKAnnotationView *)mapView:(BMKMapView *)view viewForAnnotation:(id <BMKAnnotation>)annotation
{
// 生成重用标示identifier
NSString *AnnotationViewID = @"xieheMark";
// 检查是否有重用的缓存
BMKAnnotationView* annotationView = [view dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
// 缓存没有命中,自己构造一个,一般首次添加annotation代码会运行到此处
if (annotationView == nil) {
annotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID];
((BMKPinAnnotationView*)annotationView).pinColor = BMKPinAnnotationColorRed;
// 设置重天上掉下的效果(annotation)
((BMKPinAnnotationView*)annotationView).animatesDrop = YES;
}
// 设置位置
annotationView.centerOffset = CGPointMake(0, -(annotationView.frame.size.height * 0.5));
annotationView.annotation = annotation;
// 单击弹出泡泡,弹出泡泡前提annotation必须实现title属性
annotationView.canShowCallout = YES;
// 设置是否可以拖拽
annotationView.draggable = NO;
return annotationView;
}