Skip to content

Instantly share code, notes, and snippets.

View absolutelynotjames's full-sized avatar

James absolutelynotjames

  • Durham College
  • Greater Toronto Area
View GitHub Profile
@absolutelynotjames
absolutelynotjames / leaflet-multi-geojson-layers.js
Last active March 31, 2016 00:45 — forked from pospi/leaflet-multi-geojson-layers.js
Handle multiple geoJSON layers in a Leaflet.js angular directive. Original code by @pospi, slightly modified to support the pointToLayer option.
/**
* Service to manage geoJSON layering with Leaflet.js' angular directive, which only allows 1 set of geoJSON data.
*
* Assuming you have a leaflet directive with its 'geojson' attribute set to `geojson`, usage is as follows:
* var layers = new GeoJSONLayers();
*
* layers.addLayer('myLayer', geoJSON, function(feature) { return { fillColor: '#00F' }; });
* $scope.geojson = layers.get();
*
* layers.removeLayer('myLayer');