Created
April 20, 2015 03:47
-
-
Save hanislovingit/86f7898b12cf6ee4894a to your computer and use it in GitHub Desktop.
Mapbox-creation-api-map-class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.mapbox.accessToken = 'yourMapboxAccountAccessTokenString'; | |
var mapOptions = { | |
zoomControl: false, | |
center: initExtent.center().toMapboxLatLng() | |
maxZoom: 20 // This overrides any maxZoom set on map layers | |
}; | |
var map = L.mapbox.map(containerDivId, "yourMapboxMapId", mapOptions); | |
window.setTimeout(function () { | |
var bounds = <LatLngBounds> initialExtentBounds; | |
map.fitBounds(bounds, { | |
animate: true, | |
padding: [topLeftPaddingInPixels, bottomRightPaddingInPixels] | |
}); | |
map.invalidateSize(true); // Checks if the map container size changed and updates the map if so | |
}, 1000); // I used setTimeout to give the map a little extra time to zoom to the correct extent on initial load |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment