Skip to content

Instantly share code, notes, and snippets.

@hanislovingit
Created April 20, 2015 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanislovingit/86f7898b12cf6ee4894a to your computer and use it in GitHub Desktop.
Save hanislovingit/86f7898b12cf6ee4894a to your computer and use it in GitHub Desktop.
Mapbox-creation-api-map-class
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