Leaflet showing in the browser - Javascript Leaflet

Javascript examples for Leaflet:Configuration

Description

Leaflet showing in the browser

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">

html, body, #map {
   height: 100%;
   width: 100%;
}
      </style> 
      <script type="text/javascript">
    window.onload=function(){//from   w w  w.ja  v a  2  s  .c  o  m
console.log('L', L)
const position = [51.505, -0.09];
const map = L.map('map').setView(position, 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);
console.log('map', map)
    }

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

Related Tutorials