【发布时间】:2017-07-24 09:41:34
【问题描述】:
我正在使用 Google Maps iOS SDK 并放置多个标记,并在单击标记时打开标记信息窗口。现在我想添加尚未在地图上绘制的新标记。当用户单击其本地位置以外的任何位置时,我有不同位置的列表视图,他将跳转到所选位置。直到这一切正常,但地点标记未显示错误消息:
标记设置为 selectedMarker 但不属于此地图。忽略。
我正在重新绘制选定位置上的所有标记,但它对我不起作用。 有没有办法绘制单个或多个标记并设置设置选定标记默认值。
for (int i =0; i < [getdata count]; i++)
{
LocationData *getlocation = [getdata objectAtIndex:i];
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(getlocation.lat, getlocation.longt);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.map = _mapView;
marker.title = getlocation.name;
marker.snippet = getlocation.disciption;
marker.flat = YES;
marker.icon = [UIImage imageNamed:img];
}
【问题讨论】:
-
@AntonyRapel 标记不在地图上,我需要同时绘制和选择
-
当你用 for 循环绘制标记时,它总是选择最后绘制的最后一个标记。有了这个你可以选择
[mapView setSelectedMarker:marker];
标签: ios objective-c google-maps google-maps-api-3 gmsmapview