How to implement GMSMarker drag drop on GMSMapView?

自闭症网瘾萝莉.ら 提交于 2019-12-22 04:14:35

问题


  1. I set the marker on google map but when i drag it's all of map are drag.

  2. I want drag marker when click and drag on it's

  3. and drag map when click and drag outside 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 is event on drag drop

- (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 app and debug all above event not work. but event click on marker work well.

how i implement drag drop ?


回答1:


You have to press-and-hold on the marker before it will begin dragging. I thought it wasn't working either until someone pointed this out... really needs to be in Google's documentation.



来源:https://stackoverflow.com/questions/22294545/how-to-implement-gmsmarker-drag-drop-on-gmsmapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!