【问题标题】:Remove pin mapview?删除图钉地图视图?
【发布时间】:2013-11-01 07:30:53
【问题描述】:

我正在使用 MapView 处理 GoogleMap。我在地图上触摸我的项目的一部分,我正在添加 pin。我的问题是我想删除之前可以添加的 pin。我怎么能做到这一点,我想将 Geopoint 赋予该功能。

有人可以给我建议吗?

这是我的代码:`

public void AddPoint(Drawable drawable, MapView mapView, MotionEvent motionEvent) {
        p = mapView.getProjection().fromPixels(
                (int) motionEvent.getX(),
                (int) motionEvent.getY()-50);


        final MapController mc = mapView.getController();
        mc.setZoom(16);
        CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);

        itemizedOverlay.addOverlay(new CustomOverlayItem(p,"","",""));
        mapView.getOverlays().add(itemizedOverlay);



        mc.animateTo(p);

        mapView.invalidate();
    }`

【问题讨论】:

    标签: android android-mapview


    【解决方案1】:
    mapView.getOverlays().clear();
    

    【讨论】:

    • 我可以使用它,但如果我添加 5 个 pin 并且如果我调用此代码,我认为它将删除所有 pin.İ 只想删除我可以触摸的。我不确定它是否有效?
    • 首先根据您的评论更改您的问题,,,,并且您必须在 onTouchEvent 中放入代码以清除特定项目(pin)....
    【解决方案2】:

    调用marker.remove()。要获得对标记的引用,您需要在创建标记时将它们保存到列表中,然后您可以遍历列表以找到所需的标记。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      相关资源
      最近更新 更多