第一个代码段后面没有显示地图
摘录1:
var mapEle = document.getElementById('map');
var map = L.map(mapEle);
L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright" title="OpenStreetMap" target="_blank">OpenStreetMap</a> contributors | Tiles Courtesy of <a href="http://www.mapquest.com/" title="MapQuest" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png" width="16" height="16">',
subdomains: ['otile1','otile2','otile3','otile4']
}).addTo(map);
摘录2:
var mapEle = document.getElementById('map');
var map = L.map(mapEle).setView([43.07265,-89.400929], 10);
L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright" title="OpenStreetMap" target="_blank">OpenStreetMap</a> contributors | Tiles Courtesy of <a href="http://www.mapquest.com/" title="MapQuest" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png" width="16" height="16">',
subdomains: ['otile1','otile2','otile3','otile4']
}).addTo(map);
在第一个代码段的第二行进行了更改,添加了setView([43.07265,-89.400929], 10)
,它显示了地图,我缺少某些内容,还是setview是强制性的?
更新
leaflet version: 0.7.3
答案 0 :(得分:2)
使用setView(),你告诉传单哪个瓦片是http:// {s} .mqcdn.com / tiles / 1.0.0 / map / {z} / {x} / {y} .png必须从服务器获取。
所以是的,这是强制性的