Google Maps Cluster Item Marker - Update Marker Icon - android

I'm trying to utilize the clustering from Google Maps Android API utility library. So far its working fine. One problem however arise which I don't see a apparent solution for. If I need to update an marker icon in my map view - how to do this? Since the switch to the clustering approach I don't have the Marker objects anymore and can't simply use setIcon. Also I would need to determine if the target marker is currently in a cluster (in this case it would not make sense to update the icon because it represents the whole cluster)

Found a way in DefaultClusterRenderer using the getMarker method. It seems to return Marker objects for single items so the clusters are not affected.

Related

How to set marker Z-index on MapBox Android?

My app shows a user marker. Basically, the user marker shows where the current user is on the map but I also have other markers placed on the map. In the end, it covers up my user marker. I want my User Marker to be on the top of the map. I want it to be rendered last so it shows on the very top.
Any idea?
In case anyone is looking for a newer answer for latest SDKs.
Mapbox Marker class is now deprecated in newer versions of Mapbox Android SDK. Annotations plugin is suggested instead, which has a Symbol class for markers.
In mapbox-android-plugin-annotation-v7 library Symbol class had a withZIndex() method which allowed to manipulate Z-ordering of map objects.
In mapbox-android-plugin-annotation-v8 this method was renamed to withSymbolSortKey() (which was a bit tricky to find and discover).
There is a solution from here https://github.com/mapbox/mapbox-gl-native/pull/5294
If you use MarkerView, you can bring your marker to the very top with MarkerViewManager#select call.
mapboxMap.getMarkerViewManager().select(marker);
It will end by calling View#bringToFront from Android View API, the selected marker view will show on top of all other marker views.
I think this may help:
Mapbox Android SDK: Bring marker to front
Yes. Starting with Mapbox Android SDK v4.1, the selected marker will
come to front.
You can select a marker with mapboxMap.selectMarker(marker);

Markers clustering in android gmaps v2

I am trying to implement marker clustering in android in a repeated way i.e. locations are being fetched from sql server and points are placed on map. But the problem i am facing is that the markers newly plotted or updated are not shown itself, I have to zoom in or out to see the updated markers. I have used
mclusterManager.clearItems()
but still same thing is happening. Any solution??
You need to force a recluster after adding new items doing
mclusterManager.cluster();

What's the logic behind marker selection with 2 or more overlapping marker? (Google API android v2)

If i make a tap on the map on a marker, an event gets triggered and i can catch it implementing the interface `OnMarkerClickListener. The event return me the marker on which i tapped; this is straightforward. The problem i'm facing now is that when there are 2 or more marker one on top of another, i don't know on which marker will be triggered the event. I already excluded the possibility that the first marker to be drew is the first to be selected and it seems like the choice is made at randoms, but i think this is not the case.
I would like to know how the API choose on which marker to trigger the event, between the "n" overlapping marker, and how i can control this choice.
I must say that due to some logic in my app i would like to not use Spinderfier or Marker clustering to avoid Marker overlapping; i also found this workaround to eliminate the problem i can't use it.
Sorry for my poor English and thank you for your attention.

Exclude marker from clustering - Google Maps Extension (Android app)

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.
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 Markers with the same group are clustered together, so if you change one Marker's group, you'll get the desired effect.

MapView within ExpandableListView

In my ExpandableListView I need to add Google Map on each item.
I tried with putting Map on each item but its giving me inflate exception. And its is also stated that an MapActivity can contain only one MapView.
Is there any other idea to achieve this.
For refrence you can see here.
Your comments regarding MapActivity indicate that you are using Maps V1, which is deprecated. Maps V2 does not require a MapActivity and can have multiple maps.
That being said, your proposed implementation is unlikely to work well, as putting scrollable things in scrollable things can be problematic. It also is rather unrealisitc IMHO -- whoever came up with that design has never used an actual smartphone, as there's no point in having an interactive map that small (again, IMHO).
Consider using static maps (there's a Google API for that somewhere) for inside the ExpandableListView, where a tap on the map brings up the full map, either in your app or in the standard Maps app.
I recommend to not use static map (as for example it's not possible to zoom to particular bounds with newLatLngBounds or add a circle in particular lat/lon).
I recommend to use map fragment in lite mode:
In addition, there is also a new ‘lite mode’ map option, ideal for situations where you want to provide a number of smaller maps, or a map that is so small that meaningful interaction is impractical, such as a thumbnail in a list. A lite mode map is a bitmap image of a map at a specified location and zoom level.
Map fragment can be nested in the list.

Categories

Resources