How to set marker Z-index on MapBox Android? - 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);

Related

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.

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.

How Google Maps Android API v2 handle markers outside the view are

During the CameraChange event I add new markers to the map, so I want to know if they are removed automatically when they become invisible as the camera has moved.
Does anyone have this information?
Do you mean, are markers removed when the map is panned such that the marker is no longer on the screen? If so, the answer is no, the markers are still "on the map" even when "off screen".
If you would like to remove markers as they are moved off the map, please see my answer to this question

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

Ballon on Mapview and also want to get location whenever balloon position changed on Map in android

Recently I show the ubicabs taxi booking app. I found very nice functionality inside it. In this app they have google maps for showing markers, but they have used very good UI component for that. Also I found one more uniqueness is that whenever user moves or change the position of marker through touch it will fetch the current location. One thing that I know is that it is using the onTouchEvent of Overlay but how to create that marker balloon and how to get updated location on the basis of that marker.
I am attaching a preview of that marker here. Also would like to know that how can we scroll the text inside that balloon?
The best overlay open project I have found so far is this one, link. But it is nothing compared to the picture above. Would also like to know how they created this! Great Question and picture ;)

Categories

Resources