• Is there a limitation in how many times we can add it to a single page?

    On this page I added 2 maps but it only works for one.
    https://ousontccjb.fr/?p=47

    There is a javascript error in the console:
    “Uncaught Error: Map container is already initialized.”

    Small bug?

    • This topic was modified 2 years, 9 months ago by jhurteaux.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jhurteaux

    (@jhurteaux)

    I tried to add indexes to the unique id that is generated twice but it does not seem to be enough:

    if (isNaN(window.mapIndex)) {
    		window.mapIndex = 0;
    		document.querySelectorAll('[id^="leaflet-map"]').forEach((element, index) =>  {
    		    element.classList.add("leafleft-map");
    		    element.id = element.id + "-" + index;
    		});
    	} else {
    		window.mapIndex = window.mapIndex + 1;
    	}
    
    	var map = L.map('leaflet-map-' + window.mapIndex, { dragging: !L.Browser.mobile, tap:!L.Browser.mobile });

    `

    Plugin Author axelkeller

    (@axelkeller)

    Until now there is no construction for variable number of maps. I had no need for that, but it could be done.

    There is a javascript error in the console:
    “Uncaught Error: Map container is already initialized.”

    I don’t know where this error appears, which console?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding 2 or more map per page’ is closed to new replies.