How to set my own icon for markers in clusterer in Google Maps

前端 未结 1 1827
广开言路
广开言路 2020-12-25 15:25

I\'m using GoogleMaps clustering. I have 4 different types of markers, each extends from one abstract class, each has its owm icon and it defined in MarkerOptions field. I u

相关标签:
1条回答
  • 2020-12-25 15:45

    So, it was my foolish. Again, it shows, that I should pay more attention, studying library. If somebody is interested in answer, here it is: I was right supposing, that I need to override some method in DefaultClusterRenderer. So, the full way: Create own class and extend it from DefaultClusterRenderer:

    public class OwnIconRendered extends DefaultClusterRenderer<AbstractMarker>
    

    Then override method onBeforeClusterItemRendered:

    @Override
    protected void onBeforeClusterItemRendered(AbstractMarker item,
            MarkerOptions markerOptions) {
        markerOptions.icon(item.getMarker().getIcon());
    }
    

    The way is rather simple, but it seems to me, that clustering started to work slower. So, that's enough.

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