Last active
January 2, 2019 12:29
-
-
Save codeofsumit/3f35a0ea4933cac28a1960a5838f5747 to your computer and use it in GitHub Desktop.
Create a leaflet layer from geoJSON supporting circles
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
import { forEach } from 'lodash'; | |
createLayersFromJson(data) { | |
const layers = []; | |
forEach(data, (geo, id) => { | |
L.geoJSON(geo, { | |
pointToLayer: (feature, latlng) => { | |
if (feature.properties.radius) { | |
return new L.Circle(latlng, feature.properties.radius); | |
} else { | |
return new L.Marker(latlng); | |
} | |
}, | |
onEachFeature: (feature, layer) => { | |
layer.push(layer); | |
}, | |
}); | |
}); | |
return layers; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment