OSMdroid add custom icons to ItemizedOverlay

后端 未结 1 1710
一整个雨季
一整个雨季 2020-12-31 20:51

I am using ItemizedIconOverlay class and I\'m currently displaying events on the map along with the user\'s position with the same default icon.

How do I change the

相关标签:
1条回答
  • 2020-12-31 21:08

    Presumably your mItems is an ArrayList of OverlayItems created like:

    mItems = new ArrayList<OverlayItem>();
    

    To this list you will be adding individual OveralyItems, so when you create each item you can do it like this, setting the marker before you add it to the list:

    OverlayItem olItem = new OverlayItem("Here", "SampleDescription", point);
    Drawable newMarker = this.getResources().getDrawable(R.drawable.mymarker);
    olItem.setMarker(newMarker);
    mItems.add(olItem);
    

    where mymarker is a .png in your drawables folder.

    Update - to set default marker for whole overlay, change

    this.mMyLocationOverlay = new ItemizedIconOverlay<OverlayItem>(mItems, new Glistener(), mResourceProxy);
    

    to

    this.mMyLocationOverlay = new ItemizedIconOverlay<OverlayItem>(mItems, newMarker, new Glistener(), mResourceProxy);
    

    where newMarker is as before

    0 讨论(0)
提交回复
热议问题