Skip to content

Instantly share code, notes, and snippets.

@lxbarth
Created October 26, 2012 18:59
Show Gist options
  • Save lxbarth/3960733 to your computer and use it in GitHub Desktop.
Save lxbarth/3960733 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
// See http://mapbox.com/mapbox.js/api/v0.6.6/#mapbox.auto
mapbox.auto('map', 'villeda.map-up0fpg1g', function(map, tiledata) {
var querystring = location.search.replace( '?', '' ).split( '&' ), params = {};
for (var i = 0; i < querystring.length; i++ ) {
var name = querystring[i].split('=')[0],
value = querystring[i].split('=')[1];
params[name] = value;
}
if (params.lon && params.lat) {
var features = [{
geometry: {type: "Point", coordinates: [params.lon * 1, params.lat * 1]},
properties: {image: "http://cdn.leafletjs.com/leaflet-0.4/images/marker-icon.png"}
}];
// See http://mapbox.com/mapbox.js/api/v0.6.6/#map.addLayer
map.addLayer(mapbox.markers.layer().features(features));
// See http://mapbox.com/mapbox.js/api/v0.6.6/#map.center
map.center({lon: params.lon, lat: params.lat}).zoom(14);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment