admin管理员组

文章数量:1327308

I am trying to show leaflet on my website and it just will not show, I am following the simple tutorial from .html and the tiles do not load just get a gray map, this is what I have on my page

<head>
 <script src=".7.2/leaflet.js"></script>
 <link rel="stylesheet" href=".7.2/leaflet.css" /> 
   <style type="text/css">
    #map {
        height: 180px;
        width: 500px;
    }
    </style>    
 </head>
 <body>
<div id="map">

</div>
<script>
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.cloudmade/API-key/997/256/{z}/{x}/{y}.png', {
    attribution: 'Map data &copy; <a href="">OpenStreetMap</a> contributors, <a href=".0/">CC-BY-SA</a>, Imagery © <a href="">CloudMade</a>[…]',
    maxZoom: 18
}).addTo(map);
 </script>
 </body>

Thats it the map does not show only a gray area has anybody gotten this to work? I am using internet explorer 10 but the map does not show o firefox or chrome either.

I am trying to show leaflet on my website and it just will not show, I am following the simple tutorial from http://leafletjs./examples/quick-start.html and the tiles do not load just get a gray map, this is what I have on my page

<head>
 <script src="http://cdn.leafletjs./leaflet-0.7.2/leaflet.js"></script>
 <link rel="stylesheet" href="http://cdn.leafletjs./leaflet-0.7.2/leaflet.css" /> 
   <style type="text/css">
    #map {
        height: 180px;
        width: 500px;
    }
    </style>    
 </head>
 <body>
<div id="map">

</div>
<script>
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.cloudmade./API-key/997/256/{z}/{x}/{y}.png', {
    attribution: 'Map data &copy; <a href="http://openstreetmap">OpenStreetMap</a> contributors, <a href="http://creativemons/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.">CloudMade</a>[…]',
    maxZoom: 18
}).addTo(map);
 </script>
 </body>

Thats it the map does not show only a gray area has anybody gotten this to work? I am using internet explorer 10 but the map does not show o firefox or chrome either.

Share Improve this question edited Mar 2, 2014 at 21:08 Tomasz Kowalczyk 10.5k6 gold badges55 silver badges70 bronze badges asked Mar 2, 2014 at 21:02 user3329640user3329640 1212 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7 +50

Sure. You have to take an API key from a tile service.

var map = L.map('map').setView([36.7667, 13.5833], 13);

L.tileLayer('http://{s}.tile.cloudmade./74b831354f3554faa108ac65e3/997/256/{z}/{x}/{y}.png', {
          attribution: 'Map data &copy; <a href="http://openstreetmap">OpenStreetMap</a> contributors, <a href="http://creativemons/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.">CloudMade</a>',
          maxZoom: 18
      }).addTo(map);

      var marker = L.marker([36.752866, 13.556323]).addTo(map);

Please notice 74b831354f3554faa108ac65e3. It's not going to work for you. You can use this service to get a API KEY

EDIT 27 APR 2014: CloudMade is not free anymore. You can use: MapQuest, MapSurfer.NET or openstreetmap.de

本文标签: dictionaryJavaScript leaflet map sample will not showStack Overflow