如何在GMSMapView上实现GMSMarker拖放功能? [英] How to implement GMSMarker drag drop on GMSMapView?
本文介绍了如何在GMSMapView上实现GMSMarker拖放功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
-
我在google地图上设置了标记,但是当我拖动它时,所有的地图都被拖动。
I set the marker on google map but when i drag it's all of map are drag.
当点击并拖动它的
并拖动地图,点击并拖动到标记之外时,需要拖动标记。
and drag map when click and drag outside marker.
这是我的代码
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
{
}
当我运行我的应用程序和调试所有上述事件不工作。
但事件点击标记工作很好。
when i run my app and debug all above event not work. but event click on marker work well.
我如何实现拖放?
推荐答案
您必须先按住标记才能开始拖动。我以为这是没有工作,直到有人指出这一点,真的需要在Google的文档中。
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.
这篇关于如何在GMSMapView上实现GMSMarker拖放功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文