Skip to content Skip to sidebar Skip to footer

Osmdroid, Set A Custom Icon In A Mapview

My App is using a local service, that provides changing locations. These locations are added to my ArrayList: static List weg = new ArrayList(); Th

Solution 1:

What you can do is sub-class MyLocationNewOverlay, and set your own bitmaps (mPersonBitmap and mDirectionArrowBitmap) in your constructor.

Or you can try to use this constructor:

publicMyLocationNewOverlay(IMyLocationProvider myLocationProvider, 
    MapView mapView, ResourceProxy resourceProxy)

and define your own "ResourceProxy".

Solution 2:

Thanks for the advices. Now I have found a solution. I have commented out the instruction "o.enableMyLocation();", that is responsible for standard icon. It follows the replacement for the last 4 instructions:

mapView.getOverlayManager().add(overlay);
// o.enableMyLocation(); //shows the green-arrow-marker (my own position)
mapView.getOverlays().add(o);
setMarker(); //set an own marker
mapView.postInvalidate();
.
.
voidsetMarker() {
  Drawable marker = getResources().getDrawable(R.drawable.icon);
  ItemizedIconOverlay<OverlayItem> overlay = new ItemizedIconOverlay<OverlayItem>(
          new ArrayList<OverlayItem>(), marker, null,
          new DefaultResourceProxyImpl(this));
  // gc: last GeoPoint
  OverlayItem item = new OverlayItem(null, null, gc);
  overlay.addItem(item);
  mapView.getOverlays().add(overlay);
}

Regards Wicki

Post a Comment for "Osmdroid, Set A Custom Icon In A Mapview"