代码之家  ›  专栏  ›  技术社区  ›  user2955394

如何在GMSMapView上实现GMSMarker拖放?

  •  8
  • user2955394  · 技术社区  · 11 年前
    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 回复  |  直到 7 年前
        1
  •  14
  •   friedbunny RajKrish    11 年前

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