Skip to main content
100%

Turf.Js Test

✓ Published0🌍 Public
CCliffordAnderson
Last edited Apr 21, 2016
Created on Apr 21, 2016

This example demonstrates how to calculate and display the centroid of a polygon on a map. It shows a single rectangular polygon overlaid on a Mapbox map, with its geographic center marked as a point feature. The visualization uses the Turf.js library’s `turf.centroid` function to compute the centroid from the polygon’s coordinates, then combines the original polygon and the resulting point into a GeoJSON FeatureCollection. This collection is rendered using Mapbox.js’s `L.geoJson` layer, with the map centered over the area at a zoom level that shows the full shape.

AI-generated description

Similar vizzes