29
rated 0 times
[
32]
[
3]
/ answers: 1 / hits: 198848
/ 12 Years ago, thu, october 4, 2012, 12:00:00
The following code initializes a leaflet map. The initialize function centers the map based on user location. How do I change the center of the map to a new position after calling the initialize function?
function initialize() {
map = L.map('map');
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
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>'
}).addTo(map);
map.locate({setView: true, maxZoom: 8});
}
More From » leaflet