我正在尝试创建一个jQuery手机应用程序,并且我想使用嵌入在其中的传单地图。我现在正在做一个非常基本的概念验证,但我没有太多的运气。每次我尝试加载地图时,地图的.png都不加载,控制台告诉我它的禁止。我想我可能会设置错误的地图URL,但CloudMade网站上的文档有点模糊。任何帮助,你可以提供将不胜感激。传单地图网址被禁止
代码:
var map = new L.Map('map');
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/MY_APP_KEY/997/256/{z}/{x}/{y}.png',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18});
map.addLayer(cloudmade);
map.locateAndSetView(16);
map.on('locationfound', onLocationFound);
function onLocationFound(e) {
var radius = e.accuracy/2;
var marker = new L.Marker(e.latlng);
map.addLayer(marker);
marker.bindPopup("You are within " + radius + " meters from this point").openPopup();
var circle = new L.Circle(e.latlng, radius);
map.addLayer(circle);
}
map.on('locationerror', onLocationError);
function onLocationError(e) {
alert(e.message);
}
当我尝试加载图像,我得到以下错误:GET http://a.tile.cloudmade.com/MY_APP_KEY/997/256/0/0/0.png 403(禁止)。很明显,我用我从CloudMade获得的密钥替换了MY_APP_KEY,但除此之外,我不确定还有哪些地方可以转身。
在此先感谢您的帮助。
只是做了一个快速复制和粘贴(字面瞥了一眼这个代码)和SF的地图显得很好。 – hellatan 2013-07-25 12:45:12