如何在GMSMapView上实现GMSMarker的拖放?

8
  1. 我在谷歌地图上设置了标记,但当我拖动它时,整个地图都会被拖动。

  2. 我希望在单击并拖动标记时可以拖动它。

  3. 并且在标记外单击并拖动时可以拖动地图。

这是我的代码:

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

这是有关拖放事件的内容

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

}

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

}

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

}

当我运行我的应用程序并调试时,所有上述事件都不起作用。但标记的点击事件很好用。

我该如何实现拖放?

1个回答

14

在开始拖动标记之前,您必须长按标记。直到别人指出这一点,我才意识到它没有起作用... 这真的需要出现在Google的文档中。


有没有可能像点击和拖动一样拖动? - AJ Sanjay

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接