web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Bing Map Integration with MSCRM2016.....

(0) ShareShare
ReportReport
Posted on by 2,715

Hello Experts,
I have a requirement in which i am storing the GeoCode Information value(Latitude an Longitude) in my Account Entity,again i have embeded a custom HTML Page which contain the Bing Map in a dashboard so that user can search an address .Now based upon the the user input in the Custom HTML Page i am calling Bing API in which i am getting the Latitude an Longitude information for the user entered address.Now i want to get all the Nearby Accounts (between 20M) of the the user entered address

My question is how to get all the accounts(account record has Latitude an Longitude) from CRM which are present between 20KM of the user address(i am getting Latitude an Longitude by calling Bing API)

Thanks in Advance.....

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    If you're on-prem there's an unsupported way to do it, if you're online it'll be tough.

    With online, you would have to query for each account's lat & long and calculate the distance for each one (www.movable-type.co.uk/.../latlong.html has full details but there are easier ways).

    If you're on prem, you can get it via SQL - stackoverflow.com/.../fastest-way-to-find-distance-between-two-lat-long-points  You'll want to query for all where the distance < X

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Ramakanta Profile Picture
    2,715 on at

    Thanks Aiden for your quick reply..i am not understood fully can you please elaborate it more(i.e steps)..which help me to resolve the requirement

  • Aiden Kaskela Profile Picture
    19,696 on at

    No problem. Are you on CRM Online or on prem?

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Right, so, you know the lat & long for all your account but you need their relative distance from each other.

    You have account A and want to get all the rest within X KMs. There's no way to calculate all the distances ahead of time so you need to do it on demand. There's a formula you can use to get *rough* distances between two latitude and longitude points (here's some details andrew.hedges.name/.../haversine).

    If you have 100 accounts total and you want to get your distance from them, you would have to retrieve all 100 and perform your calculation for each account and discard all the ones that are further than X KMs. That's not too bad, but if you have 100,000 accounts than it will get really slow to retrieve all that data just to do some distance calculations. You could take shortcuts by only looking for accounts in the same state, but that wouldn't help if there's an account 2 KM away but in a different state.

    If you have access to SQL, you can shortcut this immensely. Here's a rough formula I use to get back distances. It's in miles but you can convert the numbers easily enough.

    select

    account.accountid,

    account.name,

    POWER((POWER((69.1 * ( {longitude 1} - {longitude 2} + 0.00001)), 2) + POWER((53.0 * ( {latitude 1} - {latitude 2} + 0.00001)), 2)), 0.5) as Distance

    from account

    where Distance < 20

    If you had SQL access you could query have a procedure that took your starting long & lat, and a maximum distance, and return a list of results. This takes no time compared to the SDK and it's really the only way you can do it with even a small data set.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Ramakanta Profile Picture
    2,715 on at

    on prem

  • Ramakanta Profile Picture
    2,715 on at

    Thanks Aiden for such nice explanation's....

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans