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 © <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 © <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 badges1 Answer
Reset to default 7 +50Sure. 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 © <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
版权声明:本文标题:dictionary - JavaScript leaflet map sample will not show - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742203473a2432385.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论