我正在为Leaflet做快速入门教程,我不断得到一张空白地图。我正在使用JavaScript来初始化地图,但即使我假设所有的写代码,我仍然看不到地图。请帮忙,我的代码如下:
<!DOCTYPE HTML>
<div id="map">
<script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>
<script type="text/javascript">
var map = L.map('map').setView([28.23211669921875, -26.050065042385917], 10);
L.tileLayer('http://b.tilecloudmade.com/e7b61e61295a44a5b319ca0bd3150890/997/256/18/149531/108306.png', {
attribution: 'Map data © <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://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
</script>
</div>
</div>
答案 0 :(得分:5)
您对tilemap的引用似乎有误,下面的代码会为您提供切片。
<!DOCTYPE HTML>
<div id="map"/>
<script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>
<script type="text/javascript">
var map = L.map('map').setView([28.23211669921875, -26.050065042385917], 10);
//L.tileLayer('http://b.tilecloudmade.com/e7b61e61295a44a5b319ca0bd3150890/997/256/18/149531/108306.png', {
L.tileLayer('http://{s}.tile.cloudmade.com/e7b61e61295a44a5b319ca0bd3150890/997/256/{z}/{x}/{y}.png', {
attribution: 'Map data © <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://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
</script>