Created
August 22, 2016 16:56
-
-
Save adamwiggall/be95706114e907a0132d311995725e30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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