Skip to content

Instantly share code, notes, and snippets.

@adamwiggall
Created August 22, 2016 16:56
Show Gist options
  • Save adamwiggall/be95706114e907a0132d311995725e30 to your computer and use it in GitHub Desktop.
Save adamwiggall/be95706114e907a0132d311995725e30 to your computer and use it in GitHub Desktop.
(function() {
var mapThat;
mapThat = function() {
var geojson, map, markerLayer;
if (!$('#map').length) {
return;
}
map = mapbox.map('map');
map.addLayer(mapbox.layer().id('<insert mapbox id here>'));
markerLayer = mapbox.markers.layer();
mapbox.markers.interaction(markerLayer);
map.addLayer(markerLayer);
geojson = [];
$('.eq-r').each(function() {
var color, cond;
cond = $(this).data('cond');
if (cond === "c_fair") {
color = "#ffa73e";
} else if (cond === "c_poor") {
color = "#e82f2f";
} else {
color = "#2fe845";
}
geojson.push({
geometry: {
type: "Point",
coordinates: [$(this).data('long'), $(this).data('lat')]
},
properties: {
title: $(this).data('extid'),
'marker-color': color,
'marker-symbol': 'star',
'marker-size': 'medium'
}
});
});
markerLayer.features(geojson);
map.setExtent(markerLayer.extent());
};
$(function() {
mapThat();
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment