Пример #1
0
  /**
   * @see com.brantapps.polaris.api.Mappable#addMarker(com.brantapps.polaris.api.MapMarkerOptions)
   */
  @Override
  public MapMarker<?> addMarker(final MapMarkerOptions<?> mapMarkerOptions) {
    if (itemisedOverlay == null) {
      itemisedOverlay =
          new ItemizedOverlayWithFocus<OverlayItem>(
              new ArrayList<OverlayItem>(), this, getResourceProxy());
      itemisedOverlay.setFocusItemsOnTap(true);
      mapView.setUseSafeCanvas(false);
      mapView.getOverlays().add(itemisedOverlay);
    }

    final Marker marker = (Marker) mapMarkerOptions.get();
    final OverlayItem item =
        new OverlayItem(
            marker.title,
            marker.snippet,
            new org.osmdroid.util.GeoPoint(marker.latitude, marker.longitude));
    if (marker.bitmap != null) {
      item.setMarker(new BitmapDrawable(mapView.getResources(), marker.bitmap));
    } else if (marker.icon != 0) {
      item.setMarker(mapView.getResources().getDrawable(marker.icon));
    }
    if (marker.anchor == Marker.Anchor.CENTER) {
      item.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
    }

    itemisedOverlay.addItem(item);
    final MapMarker<Marker> osmMapMarker = new OpenStreetMapMarker(marker);
    overlayItemToMarker.put(item, osmMapMarker);
    return osmMapMarker;
  }
Пример #2
0
  /** @see com.brantapps.polaris.api.Mappable#clear() */
  @Override
  public void clear() {
    if (itemisedOverlay != null) {
      itemisedOverlay.removeAllItems();
    }

    if (rangeOverlay != null) {
      mapView.getOverlays().remove(rangeOverlay);
    }

    if (polylines != null) {
      for (PathOverlay polyline : polylines.values()) {
        mapView.getOverlays().remove(polyline);
      }
      polylines.clear();
    }
  }