I'm using version 1.3.1 of the Google Maps Extension and am trying to exclude a marker from being clustered. I have one marker that is set in the onCreate method of my app and it represents My Location. I want this to always be visible and not be clustered like the rest of my markers. Is this possible? I tried adding the marker before I set the clustering settings and before I called setClustering on the GoogleMaps object, but it doesn't seem to work.
问题:
回答1:
If you are using just one Marker
which should not be clustered with all other, you can see a workaround in comment #2 here:
https://code.google.com/p/android-maps-extensions/issues/detail?id=10#c2
Basically using SupportMapFragment.getMap().addMarker(...)
instead of SupportMapFragment.getExtendedMap()
The problem is you will get null in GoogleMap
callbacks like onMarkerClick
, but for just one Marker
you can find out it's "the Marker". Clustering engine will not be aware of Marker
added that way.
You will also have class name collision, so you have to use full class name for original library like com.google.android.gms.maps.model.Marker
in case you keep a reference to this Marker
.
Hope it helps until this improvement is implemented.
Edit:
This is available as of version 1.5 via simple call:
theMarker.setClusterGroup(777);
The default group is 0
and only Marker
s with the same group are clustered together, so if you change one Marker
's group, you'll get the desired effect.