javascript - trying leaflet tutorial I get a broken map -


i have followed leaflet "get started" tutorial

but map looks broken , polygons not on map in example:

example: enter image description here

my map html:

enter image description here

my html

<html>    <head>    <title></title>    <link rel="stylesheet" href="elad_map.css" />    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />  </head>    <body>    <div id="map"></div>      <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>    <script type="text/javascript" src="elad_map.js"></script>  </body>    </html>

document.onload = loadmap();    function loadmap() {    var map = l.map('map').setview([51.505, -0.09], 13);        l.tilelayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accesstoken}', {      attribution: 'map data &copy; <a href="http://openstreetmap.org">openstreetmap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">cc-by-sa</a>, imagery © <a href="http://mapbox.com">mapbox</a>',      maxzoom: 18,      id: 'your.mapbox.project.id',      accesstoken: 'your.mapbox.public.access.token'    }).addto(map);        var circle = l.circle([51.508, -0.11], 500, {      color: 'red',      fillcolor: '#f03',      fillopacity: 0.5    }).addto(map);      var polygon = l.polygon([      [51.509, -0.08],      [51.503, -0.06],      [51.51, -0.047]    ]).addto(map);    }

there few things cause , related css. please make sure leaflet's css loaded checking networktab in developer tools:

enter image description here

if it's loaded correctly have other css rules in place (elad_map.css) interfere leaflet's css rules.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -