9

I have a table with geo location results in which the user can click to set that location in the map. The map is already loaded, and the user might have paned/scolled, and all those locations might be out of sight.

So when the user clicks the button for a location in the table, I need to check if that marker is already visible in the map. And only if invisible, call to setView and zoom into that location; otherwise, I just change the color of the marker (no pan, no zoom).

Has leaflet any API to check if a layer/marker is currenlty been rendered in the map?

Mariano Desanze
  • 7,847
  • 7
  • 46
  • 67

1 Answers1

28

Probably map.getBounds().contains(myMarker.getLatLng())

References:

ghybs
  • 47,565
  • 6
  • 74
  • 99