Introducing the MapBox JavaScript API

July 25 2012 by Tom MacWright

MapBox now has a JavaScript API that makes building web maps faster, simpler, and more repeatable. It combines the open source projects that we’ve been developing for more than two years, including Wax, Easey, markers.js, and the community map client project Modest Maps. This API will form the basis of our future site development as well as the interface to MapBox Hosting.

The project itself is open source, but it’s also available hosted on the same lightning fast stack as MapBox, so there’s no need to download the code yourself - just include it in a script tag.

mapbox.js on GitHub

This project emphasizes stability, consistency, and performance. The JavaScript weighs less than 50KB (gzipped and compressed) and is aggressively cached in browser and in our worldwide CDN. The code is covered by test suites powered by Jasmine and run in both modern browsers and Internet Explorer from 7 up.

We’ve also made a special effort to improve and unify documentation, so you don’t need to go searching for function signatures or useful examples. The main JavaScript API site includes a getting started section as well as information on HTML and CSS styling and the JavaScript API - and we’re planning on dramatically improving its structure as we go.

The API aims to simplify and unify - under the mapbox interface, you can set up tile layers with mapbox.layer, markers with mapbox.markers.layer and a map with mapbox.map. Controls, taken from the Wax project, now have common interfaces and are automatically attached to maps.

JavaScript API Gallery

We’ve also been working on a great new examples gallery with examples from the simplest map possible to cool animated markers with markers.js. As the API grows and we find more and more uses for it, this gallery will only grow.

Try it out, and see how much your site building experience can improve. As always, if you have any questions, hit us up in the support forum.