How to generate a polygon around a GeoJson point in web mercator projection

246 Views Asked by At

I am building a tool to display markers on a map at varying heights in Mapbox GL Js. Mapbox currently lacks the ability to give a marker a height, and the geoJson point is not rendered on its own.

How can I generate a hexagon around a GeoJson point that will follow the EPSG:3857 projection, for me to render on my map?

2

There are 2 best solutions below

1
Xavier Burger On BEST ANSWER

I found that Turf.js was all I needed. There is a circle method that will generate a polygon around a point taking in a number of steps and radius.

0
Steve Bennett On

You don't need to worry about the projection - Mapbox GL JS will project it for you.

You may be able to use Turf's hexGrid method to generate a single hexagon.