Avoid areas/polygons

I would like to avoid a circle of radius x around many lat/lng coordinates in the simplest method. Is there way to use avoid polygons without creating an algorithm to generate an array of lat lngs to build the necessary circles required. If you know of any algorithm that does that it would also help.

Thanks

Hi @Armaanm11,

the avoid_polygons parameter only takes geojson as values. So you will have to generate your circles as polygons.
You could use leaflet to create L.Circle objects around the points and convert them to geojson.
You could also use mathematics to create the points “by hand” (). Or search online for an algorithm that you can copy, there should be enough.

Best regards

Hi,

I gave the L.Cicle a try however i’m not too sure how to implement it. If you don’t mind and have some extra time, would it be possible to provide an example using L.circle?

Thanks

Hmm i just double checked, the L.circle:
It seems the toGeoJson method of the leaflet object only saves it as a Point in GeoJSON.
So it doesn’t seem possible with L.circle afterall.(See https://github.com/Leaflet/Leaflet.draw/issues/390)

You might have to look into this direction: https://stackoverflow.com/questions/5300938/calculating-the-position-of-points-in-a-circle
and generate the points using a function to generate your points on the circle and save them as geojson

Best regards