Вот реализация кода javascript без использования функции Google.
/**
* calculates the distance between position 1 and position 2
**/
function distanceBetween(pos1, pos2) {
return Math.sqrt(Math.pow(pos1[0]-pos2[0],2) + Math.pow(pos1[1]- pos2[1],2))
}
/**
* checks if the given user position is in the circle with given radius
**/
function containsLocation(middleCircle, userPosition, radius) {
if(distanceBetween(middleCircle, userPosition) <= radius) {
return true
}
return false
}
let circleRadius = 0.5 // radius of the circle
let circleMiddle = [4,4] // x and y position of the middle of circle
let userPosition = [4,5] // x and y position of the user
console.log(containsLocation(circleMiddle, userPosition, circleRadius)) // false
circleRadius = 2
circleMiddle = [4,4]
userPosition = [4,5]
console.log(containsLocation(circleMiddle, userPosition, circleRadius)) // true