You need to sign in to do that
Don't have an account?
Ola Bamidele
Geolocation - Displaying distance of accounts on Map
Hi Gurus,
I have build a Geolocation app that displays the location of an Account on a map. However to improe and take it further, I have decided to add a function that displays the "Distance" of the account to the person that is viewing the map.
After days of research, this is how far I have come but I still cant get it work. So please if anyone knows what i am doing wrong or how to make it work, please let me know!
My Code:
Error Message (which doesnt make much sense):
Thanks very much!
I have build a Geolocation app that displays the location of an Account on a map. However to improe and take it further, I have decided to add a function that displays the "Distance" of the account to the person that is viewing the map.
After days of research, this is how far I have come but I still cant get it work. So please if anyone knows what i am doing wrong or how to make it work, please let me know!
My Code:
public with sharing class AccountController { @AuraEnabled public static List<Account> findAll() { return [SELECT id, name, Location__Latitude__s, Location__Longitude__s, Industry FROM Account WHERE Location__Latitude__s != NULL AND Location__Longitude__s != NULL LIMIT 50]; DISTANCE(GEOLOCATION(BillingLatitude , BillingLongitude ), Account_Name__r.GeoLocation__Latitude__s , Branch_Assigned__r.GeoLocation__Longitude__s ) , 'mi') } }
Error Message (which doesnt make much sense):
Expecting ';' but was: ','
Thanks very much!
Account_Name__r.GeoLocation__Latitude__s , Branch_Assigned__r.GeoLocation__Longitude__s ) ,
'mi') does not make sense. It is in the wrong place. Your method returns a list of all the Accounts in your system that have a Geolocation. Then out of the blue you call the DISTANCE function!! Which account's distamce is it supposed to calculate from the viewer?!
You can modify it as you deem fit.
Thanks for the response and sorry for causing you a coding headache :D
I tried the code yiu suggested and there where a few error - but i think it is relation to the fact I dont have a UserLocate field.
Also to add, the idea to have it automatically use the Geolocation of the user of the app, rather than a fixed location. Will this be achieveable?
Thanks very much for teh help!
If I understand your question correctly, you want to be able to automatically detect the current location of your app user and then work out the distance to the Accounts. That is quite complex, beyond me. Hopefully someone else in the communuty can help.
Exactly, thats what i am trying. Totally understandable, it is very complex hint why I needed help.
nevertheless take very much for your time :)