Refresh Map by a drop down - Javascript Leaflet

Javascript examples for Leaflet:Map

Description

Refresh Map by a drop down

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.css"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2.rc.2/leaflet.js"></script> 
      <style id="compiled-css" type="text/css">

#map {//from   ww w  .j  av a2s  .c o  m
   height: 500px;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var map = L.map("map");
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png").addTo(map);
map.setView([51.5, 0], 10);
document.getElementById("buttonParis").addEventListener("click", function () {
   map.flyTo([48.8, 2.4], 10, {
        animate: true,
        duration: 2 // in seconds
    });
});
document.getElementById("buttonLondon").addEventListener("click", function () {
   map.flyTo([51.5, 0], 10, {
        animate: true,
        duration: 2 // in seconds
    });
});
    }

      </script> 
   </head> 
   <body> 
      <div id="map"></div> 
      <button id="buttonParis">Fly to Paris</button> 
      <button id="buttonLondon">Fly to London</button>  
   </body>
</html>

Related Tutorials