_{current}and the store coordinates (latitude,longitude)

_{stored}to find out the actual distance. If the actual distance is smaller or equal to the proximity radius you'll have to sound the alarm.

If you are unsure how to calculate the distance between two pairs of coordinates, see here: Calculate distance, bearing and more between Latitude/Longitude points[^].

**[Edit]**

JavaScript

var R = 6371; // earth's radius in kilometers (km) var dLat = (lat2-lat1).toRad(); // Conversion to radians can also be achieved by lat1 * Math.PI / 180 var dLon = (lon2-lon1).toRad(); // Conversion to radians can also be achieved by lat1 * Math.PI / 180 var lat1 = lat1.toRad(); // Conversion to radians can also be achieved by lat1 * Math.PI / 180 var lat2 = lat2.toRad(); // Conversion to radians can also be achieved by lat2 * Math.PI / 180 var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; // This now holds the distance expressed in km

**[/Edit]**

Any questions left?

Regards,

Manfred

I hope you can work it out now!