leaflet - if setView in map is not called it doesn't display map? -
following first code snippet doesn't display map
snippet 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); snippet 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); made alter in sec line of first snippet, added setview([43.07265,-89.400929], 10), displays map, missing something, or setview compulsory?
update
leaflet version: 0.7.3
with setview(), tell leaflet tile(s) http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png must fetched server.
so yes compulsory
leaflet
No comments:
Post a Comment