How to implement drag and drop GMSMarker on GMSMapView?

  • I set the marker on the google map, but when I drag it, all the cards are dragged.

  • I want the drag handle to click and drag it

  • and drag the map when you click and drag the external marker.

this is my code

self.camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6 bearing:0 viewingAngle:0]; self.Map = [GMSMapView mapWithFrame:self.MapView.bounds camera:self.camera]; self.Map.myLocationEnabled = YES; self.Map.delegate = self; GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = self.camera.target; marker.draggable = YES; marker.title = @"Sydney"; marker.snippet = @"Australia"; marker.map = self.Map; marker.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]]; marker.appearAnimation = kGMSMarkerAnimationPop; [self.MapView addSubview:self.Map]; 

and this event when you drag

 - (void) mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker { } - (void) mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker { } - (void) mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker { } 

when I run my application and debug all the above event, it doesn't work. but the event click on the marker to work well.

How do I implement drag and drop?

+8
ios objective-c google-maps drag-and-drop google-maps-sdk-ios
source share
1 answer

You must press and hold the handle before it starts to drag. I thought this didn't work until someone pointed it out ... really should be in the google documentation.

+12
source share

All Articles