Announcements
Hi
I have a custom entity 'Property' that stores the address details along with Latitude and Longitude. I want to be able to perform a search on this entity and find all properties within a certain radius (say 5km) of a given address. Does anyone know how this can be achieved?
Thanks
*This post is locked for comments
Hi Mir,
Below could be some of the options for you to achieve this
1. Use Bing or google maps and ingrate your CRM. Not sure how much you can full fill your businees requirements with this.
2. Use 3 rd party tools like nutshell to achieve this www.nutshell.com/.../introducing-nutshell-maps
3. Custom code either JS or Plugin to find and associate the properties based on their long and lat
Algorithams to achieve this are well explained in the below article
www.movable-type.co.uk/.../latlong.html
stackoverflow.com/.../calculate-distance-between-two-latitude-longitude-points-haversine-formula
function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c; // Distance in km
return d;
}
function deg2rad(deg) {
return deg * (Math.PI/180)
}
André Arnaud de Cal...
294,137
Super User 2025 Season 1
Martin Dráb
232,877
Most Valuable Professional
nmaenpaa
101,158
Moderator