Skip to content

Instantly share code, notes, and snippets.

@geog4046instructor
Last active October 6, 2023 03:38
Show Gist options
  • Save geog4046instructor/1b9c42e18d215a811ad5f05cacc75006 to your computer and use it in GitHub Desktop.
Save geog4046instructor/1b9c42e18d215a811ad5f05cacc75006 to your computer and use it in GitHub Desktop.
Leaflet - Create circles to represent GeoJSON point data
/*
* This example shows how to use circle markers to represent GeoJSON point data
* instead of Leaflet's default blue marker. This snippet assumes the map (map),
* basemap (streets), and GeoJSON (myLayerData) have already been declared.
*/
// create an object with a list of options to style the circle marker
// see http://leafletjs.com/reference-1.3.0.html#path for additional options
var myLayerStyle = {
color: 'Orange',
radius: 5
}
// create a vector circle centered on each point feature's latitude and longitude
function createCircles (feature, latlng) {
return L.circleMarker(latlng, myLayerStyle)
}
// create an options object that specifies which function will called on each feature
var myLayerOptions = {
pointToLayer: createCircles
}
// create the GeoJSON layer from the myLayerData object (not shown in this snippet)
L.geoJSON(myLayerData, myLayerOptions).addTo(map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment