I have a GPS Coordinate of a spot called spotCoordinates
and a center the a circle coordinates this.state.center
and a radius in kilometers this.state.radius
I'm trying to make a method to check if the spotCoordinates
is inside a circle but I don't know how I can add the radius to the coordinates and how to check if it's actually inside or not. It would be easier if it was a square.
calculateParkingSpotsInTheArea = () => {
this.state.parkingSpots.map(spot => {
let spotCoordinates = spot.coordinates;
console.log(spotCoordinates, this.state.center, this.state.radius);
// Calculate if the parking spot is inside the circle
});
}
E.g Values printed in the console spotCoordinates = [41.5408446218337, -8.612296123028727] center = {lat: 41.536558, lng: -8.627487} radius = 25
Any help?