【问题标题】:How to implement GMSMarker drag drop on GMSMapView?如何在 GMSMapView 上实现 GMSMarker 拖放?
【发布时间】:2014-04-13 05:23:07
【问题描述】:
  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
{

}

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

我如何实现拖放?

【问题讨论】:

    标签: ios objective-c google-maps drag-and-drop google-maps-sdk-ios


    【解决方案1】:

    您必须按住标记才能开始拖动。在有人指出这一点之前,我认为它也不起作用……确实需要在 Google 的文档中。

    【讨论】:

    • 是否有可能像点击和拖动一样拖动
    猜你喜欢
    • 2016-03-19
    • 1970-01-01
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 2019-06-29
    相关资源
    最近更新 更多