I am trying to figure out how to handle multiple markers on the exactly same spot.
Yes, exactly the same street number, street name, municipality, latitude, longitude, so on. So they perfectly overlap each other in the map when their markers are drawn.
When it happens, sometimes one POI appears on the top of others, and sometimes another one appears on the very top.
(because I am creating the markers as they are ordered in queried JSON file)
This doesn’t look very good in the map, and some users could consider this as an error because the same marker changes its information (such as name, images, etc) every time when the user refreshes the map.
It seems Google maps have some solutions for this issue, like below.
Does TomTomMap has any solutions for this? Any suggestions or help would be nice.
There is no straightforward way to do that, as we do not have a single method which would return something like an array of all markers under a particular location.
You can do a workaround with a couple easy steps:
onMarkerClick is called, find all marker under same location by filtering markers from
- Create new temporary markers around same location such they will be visible for the user.
- When user will start panning or zooming the map, remove temporary markers and if necessary store any needed data somewhere else for further processing.
I’m not sure whether it’ll help with your use case, but maybe it is one of the possible solution for you.
Let me know if you’ll have more questions.
Thank you for the answer.
I started implementing the solution you suggested, but I found some question while working on this.
when marker is touched/clicked, the marker balloon view is inflated by default.
Because the first touch should be only creating temporary markers around the same location, I disabled inflation by calling marker.canShowBalloon(false)
Now I want to display the marker balloon view by calling a method.
So here’s my question. is there a method that can inflate the marker balloon view when it is called? or am I only allowed to set the condition with canShowBalloon() method?
You can try to use
marker.select() together with
marker.deselect() method to show the balloon. The SDK team is working to improve that feature so that it’ll be easier in the future.
If I understood your idea correctly, then I think that you don’t need to use it. You can disable ballon on all “center” markers, but the temporary markers around can have their balloons enabled (I think).