-1

I have multiple markers set around on the map. What I want to know is how can I show only a few markers depending on the zoom level. For example: I have a zoom on the map with radius: the length between the center of the map and the bounds of the screen (lets say this is like 2km in real life not sure if this is true) so I want to show only the markers that are inside the radius. And of course if the user zooms out the radius will be recalculated again from the center point of the map to the bound of the screen. And again include markers that are inside the new radius. How can I achieve this?

user3182266
  • 1,270
  • 4
  • 23
  • 49

1 Answers1

0

I have thought about this problem and here could be an approach.

  1. you can loop through your available markers and find distance from the center of your given circle (since we're talking about a radius) to the marker; this can be done using computeDistanceBetween(); for more info see link

  2. If the marker lies within your radius, show, otherwise, hide using the setVisible() method. For more information, see link

Hope this gives you some idea.

Community
  • 1
  • 1
so_jin_ee
  • 802
  • 6
  • 7