You need to sign in to do that
Don't have an account?

Create a list of accounts and access their fields
Hello developers,
I am tackling a problem which is probably quite straight forward but I can't figure it out:
I have extend the code from https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_maps_example.htm to fit my needs.
In there I have
I am tackling a problem which is probably quite straight forward but I can't figure it out:
I have extend the code from https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_maps_example.htm to fit my needs.
In there I have
public List<Map<String,Double>> locations { get; private set; }which later gets reffered to here:
// SOQL query to get the nearest warehouses String queryString = 'SELECT Id, Name,AD_JobAds_Anz__c,Vollst_ndiger_Name__c,ShippingStreet,LocateCity__longitude__s, LocateCity__latitude__s ' + 'FROM Account ' + 'WHERE DISTANCE(LocateCity__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 3 and Kundenstatus_Direktvertrieb__c = \'Bestandskunde\' and Id != :theaccId ' + 'ORDER BY DISTANCE(LocateCity__c, GEOLOCATION('+lat+','+lon+'), \'km\') '; List <Account> warehouses = database.Query(queryString); if(0 < warehouses.size()) { // Convert to locations that can be mapped locations = new List<Map<String,Double>>(); for (Account wh : warehouses) { locations.add( new Map<String,Double>{ 'latitude' => wh.LocateCity__latitude__s, 'longitude' => wh.LocateCity__longitude__s
Now I am trying to access the fields/values of the account but since it is a List of Maps, this is not working. I have to tranform it to a list that contains the Accounts/sObject?? Then I can access its fields?
Maybe some can share some insights.
Thanks!
Then in my VF Page:
GeoLocPosition__c is formula field that allows me to get the latitude and longitude in the same format as the "locations" Map did:
"{latitude="&TEXT(LocateCity__Latitude__s)&",longitude="&TEXT(LocateCity__Longitude__s)&"}"
All Answers
Were you getting any errors or were you getting different results than expected?
Regards,
Anutej
Hello Anutej,
thank you for your reply. It seems like I did not emphazise enough on my actual goal. In my Visualforce Page I am trying to access the accounts I got from my query. As for now it looks like this
I want to be: so that for every Marker the actual accountname will get displayed.
This is not working because 'locations' does not allow me to access the accounts field. Unfortunately I am just modifying existing code and am not a developer myself. I was told that locations is a list of Maps but I need to make it a list of accounts to access to the geoloc plus account fields.
I am pretty lost with this part here:
Then in my VF Page:
GeoLocPosition__c is formula field that allows me to get the latitude and longitude in the same format as the "locations" Map did:
"{latitude="&TEXT(LocateCity__Latitude__s)&",longitude="&TEXT(LocateCity__Longitude__s)&"}"