Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created January 29, 2013 20:22
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 tmcw/4667403 to your computer and use it in GitHub Desktop.
Save tmcw/4667403 to your computer and use it in GitHub Desktop.
/**
* @author MatthewBaker
*
* Requires the style
*
* .custom-marker {
pointer-events: all;
position:absolute;
width:20px;
height:20px;
}
added to the CSS
*/
function loadInit() {
mapbox.load('openingofdetroit.map-wlpt10au', function(o) {
var map = mapbox.map('map');
map.addLayer(o.layer).zoom(12).center({
lat : 42.35584353484354,
lon : -83.04361291891475
});
var markers = mapbox.markers.layer().url('OOD_Voices.geojson').factory(function(feature) {
var div = document.createElement('div');
div.className = 'custom-marker';
var img = div.appendChild(document.createElement('img'));
img.src = 'http://dummyimage.com/20x20/bd00bd/fff';
return div;
});
mapbox.markers.interaction(markers).formatter(function(feature) {
var div = document.createElement('div');
var title = div.appendChild(document.createElement('h1'));
title.innerHTML = feature.properties["What's you"];
return div;
});
map.addLayer(markers);
map.ui.hash.add();
map.ui.zoomer.add();
map.ui.zoombox.add();
map.interaction.auto();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment