Exemplo n.º 1
0
  private void resetMarkersOverlay() {
    if (mMarkersOverlay != null) {
      mMarkersOverlay.removeAllItems();
      mMapView.removeOverlay(mMarkersOverlay);
    }

    mMarkersOverlay =
        new ItemizedDraggableIconOverlay(
            getActivity().getApplicationContext(),
            new ArrayList<Marker>(),
            new ItemizedIconOverlay.OnItemGestureListener<Marker>() {
              @Override
              public boolean onItemSingleTapUp(int index, Marker item) {
                mMapView.selectMarker(item);
                return true;
              }

              @Override
              public boolean onItemLongPress(int index, Marker item) {
                mMapViewListener.onLongPressMarker(mMapView, item);
                return true;
              }
            });
    mMarkersOverlay.setMarkerDragListener(mMarkerDragHandler);
    mMapView.addItemizedOverlay(mMarkersOverlay);
  }
Exemplo n.º 2
0
  @Override
  public void updateMarker(MarkerInfo markerInfo, boolean isDraggable) {
    // if the drone hasn't received a gps signal yet
    final Coord2D coord = markerInfo.getPosition();
    if (coord == null) {
      return;
    }

    final LatLng position = DroneHelper.CoordToLatLng(coord);
    Marker marker = mBiMarkersMap.getValue(markerInfo);
    if (marker == null) {
      marker = new Marker(mMapView, markerInfo.getTitle(), markerInfo.getSnippet(), position);
      mMarkersOverlay.addItem(marker);
      mBiMarkersMap.put(markerInfo, marker);
    } else {
      marker.setTitle(markerInfo.getTitle());
      marker.setDescription(markerInfo.getSnippet());
      marker.setPoint(position);
    }

    // Update the marker
    final Resources res = getResources();
    Bitmap markerIcon = markerInfo.getIcon(res);
    if (markerIcon == null) {
      markerIcon = BitmapFactory.decodeResource(res, R.drawable.ic_action_location);
    }

    marker.setIcon(new Icon(new BitmapDrawable(res, markerIcon)));

    marker.setAnchor(new PointF(markerInfo.getAnchorU(), markerInfo.getAnchorV()));
    marker.invalidate();
    mMapView.invalidate();
  }
Exemplo n.º 3
0
 private void removeMarkersOverlay(List<Marker> markers) {
   if (mMarkersOverlay != null) {
     mMarkersOverlay.removeItems(markers);
   }
 }