jig*_*igs 11 iphone google-maps ios gmsmapview
我正在整合谷歌地图sdk.一切正常.但是当第二个出现时如何删除特定标记(Pin Point).(我不使用Mapkit)
我想要以下内容:
如果我点击地图然后现在在该位置生成一个标记引脚,如果我点击地图上的另一个位置然后显示两个引脚但我想要移除旧的标记引脚.
我也用,
[self.mapView clear];
Run Code Online (Sandbox Code Playgroud)
但很明显GMSMapview中的所有其他标记点.
以下是在地图上添加图钉的代码:
GMSMapView *mapView;
GMSMarker *currLocMarker = [[GMSMarker alloc] init];
currLocMarker.map = nil;
[currLocMarker setTitle:NSLocalizedString(@"current_location_title", nil)];
currLocMarker.icon = [UIImage imageNamed:@"pin_fetch_location.png"];
currLocMarker.position = CLLocationCoordinate2DMake(pCoordinate.latitude, pCoordinate.longitude);
currLocMarker.map = self.mapView;
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题.. !!
提前致谢..:)
Spy*_*ydy 25
要从GMSMapView中删除特定引脚,请保留引脚的引用(如果有多个则使用数组),然后使用此代码
currLocMarker.map = nil;
Run Code Online (Sandbox Code Playgroud)
要从GMSMapView中删除包括引脚多边形线在内的所有内容,请使用此代码
[ _mapView clear];
Run Code Online (Sandbox Code Playgroud)
是的,我得到了这个解决方案。添加引脚如下:
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinates {
pCoordinate.latitude =coordinates.latitude;
pCoordinate.longitude =coordinates.longitude;
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(coordinates.latitude, coordinates.longitude) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
{
[currLocMarker setTitle:NSLocalizedString(@"current_location_title", nil)];
currLocMarker.icon = [UIImage imageNamed:@"pin.png"];
currLocMarker.position = CLLocationCoordinate2DMake(coordinates.latitude, coordinates.longitude);
currLocMarker.map = self.mapView;} ] ;}
Run Code Online (Sandbox Code Playgroud)
如果您在上面使用过,请删除以下行:
GMSMarker *currLocMarker = [[GMSMarker alloc] init];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24950 次 |
| 最近记录: |