Markers clustering in android gmaps v2 - android

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();

Related

Google map clusteritem click event not working when it above a marker

I'm using the android clustering utility on a map and succesffuly implemented an onclick listener with mClusterManager.setOnClusterItemClickListener() for the cluster items.
Because I also want some markers to always be unclustered, I also add some markers without using the mClusterManager but directly using the map's mMap.addMarker(), this way I'm sure that they are never clustered on the map.
My problem is that I when a clusterItem or a cluster overlay a marker,the function OnClusterClickListener not work. When i Separate then form each other it work again
Is there a way to solve my problem?
Thank you

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);

Google Maps Cluster Item Marker - Update Marker Icon

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.

Android map v2 : Marker display order

I'm writing an android app using v2 of the maps API. I have a couple of different types of markers being displayed on the map, one of which I always want to be shown over the others.
I've tried adding that marker to the map last, but it still seems to end up with other markers being displayed over the top of it depending on the relative position of the markers.
Does anyone have a way of forcing a given marker to always be shown on top?
The way to bring an item to the front is by calling .showInfoWindow();
Check out this post on how to bring a clicked item to front.
Google Maps v2 Marker zOrdering - Set to top

Best Way to Add Map Pins to Google Map Android

I have been successful at adding the pins but I need the pins to be refreshed when the user clicks on the map and provides a new location, I get an error. Keep in mind that I need this to happen in the background so that it does not affect the map interaction.
My problem is that when the user clicks on the map the list of map pins is already being updated and I get an ConcurrentModificationException error.
Basically, I have a JSONArray which has locations. I need each location to be on the map and when the new location is touched the pins are updated and the old pins are cleared.
Any suggestions on how to make this more friendly and easier. I cannot seem to get rid of the ConcurrentModificationException error.
Here is the "the missing widget"...
Balloons without icons: https://github.com/jgilfelt/android-mapviewballoons#readme
Balloons with icons (extends Jeff Gilfelt's project): https://github.com/galex/android-mapviewballoons

Categories

Resources