Remove particular GMSMarker from GMSMapview using Google Map sdk in ios

后端 未结 9 3152
-上瘾入骨i
-上瘾入骨i 2021-02-19 23:18

I am integrating google maps sdk. Its all work fine. But how to remove particular Marker(Pin Point) when second will appear.(I am not using Mapkit)

I want the following:

9条回答
  •  鱼传尺愫
    2021-02-20 00:01

    Yes, I got that solution. Add pin like the following:

    - (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;} ] ;}
    

    Please remove the following line if you used in the above:

    GMSMarker *currLocMarker = [[GMSMarker alloc] init];
    

提交回复
热议问题