Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created July 15, 2015 02:24
Show Gist options
  • Save chriscalip/37df8bc7becbc8a10453 to your computer and use it in GitHub Desktop.
Save chriscalip/37df8bc7becbc8a10453 to your computer and use it in GitHub Desktop.
JS code snippet of geojson into leaflet layers.
jQuery.each(marketAreas, function (key, marketArea) {
parsedMarketArea = {
'type': 'Feature',
'properties' : marketArea.properties,
'geometry' : jQuery.parseJSON(marketArea.geometry)
};
maOverlayGroups[marketArea.properties.title] = L.geoJson(parsedMarketArea, {
'style': mapPolygonSettings,
'onEachFeature': function (feature, layer) {
var area_content = themeString(
area_theme,
'/node/' + feature.properties.nid,
feature.properties.title
);
layer.bindPopup(area_content, {className: 'map-popup'});
}
});
//maOverlayGroups[marketArea.properties.title] = new L.layerGroup().addTo(map);
maOverlays[marketArea.properties.title] = maOverlayGroups[marketArea.properties.title];
});
var controlMarketAreas, controlMarketAreasDiv;
L.control.layers(null, maOverlays, {
collapsed: true
}).addTo(map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment