1

I work on a map with leaflet, I want a certain level of zomme its declache a event this avenemet is to appear an image on the map

function initialisation() {

  var mymap = L.map('mapid').setView([49.621522, 5.863455],13)// carte map et 13 c'est le zoom
  var marker = L.marker([49.621522, 5.863455]).addTo(mymap).on('click', onClick);//déclaration de la varibale Marker pour tracer une place sur Map;  

function onClick() 
  {scene(L, mymap, currentPoint);}

function scene(L, mymap, currentPoint) {

  $.getJSON('data/emplacement.json', function(data){//data c'est la liste
  for (let objet of data) { // une boucle parcour la liste des objets JSON

JSON picture contains some image I want a certain level of zoom his release the scene function

I did not know what I'm going to put a loop for the creation of layers

trinaldi
  • 2,872
  • 2
  • 32
  • 37
kader
  • 13
  • 3
  • Did you check this [answer](https://stackoverflow.com/questions/995914/catch-browsers-zoom-event-in-javascript/6085253)? – trinaldi Apr 08 '19 at 00:36

2 Answers2

0

Leaflet has a way to get the level of zoom how is explained here in their documentation. So basically you should be able to get the zoom level in which you want to dispatch the action you mention.

Community
  • 1
  • 1
rasfuranku
  • 78
  • 1
  • 1
  • 10
  • YES my zoom level is well defined 13 ;; var mymap = L.map ('mapid'). SetView ([49.621522, 5.863455], 13) ;; but I do not know how I trigger the event – kader Apr 08 '19 at 09:44
0

You can use the event zoomend and then get the zoom level and do what you want after.

mymap.on('zoomend', function() {
    let zoomLevel = map.getZoom();
    if (zoomLevel === 13) {
        // Do something
    }
});
Baptiste
  • 1,688
  • 1
  • 15
  • 25