make a Simple Leaflet Map - Javascript Leaflet

Javascript examples for Leaflet:Map

Description

make a Simple Leaflet Map

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://unpkg.com/leaflet@1.0.3/dist/leaflet.css"> 
      <script type="text/javascript" src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script> 
      <style id="compiled-css" type="text/css">

#map {//from   w  ww.  jav a2  s.c  om
   width: 300px;
   height: 300px;
   background-color: black;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
    }

      </script> 
   </head> 
   <body> 
      <div id="map"></div>  
   </body>
</html>

Related Tutorials