For example, the zoomend event worked, how to get the objects that are visible on the map now?
map.on('zoomend', function(ee) { }); For example, the zoomend event worked, how to get the objects that are visible on the map now?
map.on('zoomend', function(ee) { }); What objects do you want to receive? If, for example, you have an associative array of markers marks , then you can get visible ones from them as follows:
map.on('zoomend', function(ee) { var bounds = map.getBounds(); // Π³ΡΠ°Π½ΠΈΡΡ Π²ΠΈΠ΄ΠΈΠΌΠΎΠΉ ΠΎΠ±Π»Π°ΡΡΠΈ ΠΊΠ°ΡΡΡ for (var key in marks) { // ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌ ΠΌΠ°ΡΡΠΈΠ² ΠΌΠ°ΡΠΊΠ΅ΡΠΎΠ² if (marks.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) { var lat_lng = marks[key].getLatLng(); // ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΠΌΠ°ΡΠΊΠ΅ΡΠ° if (bounds.contains(lat_lng)) { // ΠΏΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ, ΠΏΠΎΠΏΠ°Π΄Π°Π΅Ρ Π»ΠΈ ΠΌΠ°ΡΠΊΠ΅Ρ Π² Π³ΡΠ°Π½ΠΈΡΡ ΠΎΠ±Π»Π°ΡΡΠΈ console.log(lat_lng); } } } }); Source: https://ru.stackoverflow.com/questions/514798/
All Articles