function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RajivRajiv 

Google Map Lighting help needed

Hey Guys,
I am trying to implement google map using lighting. I really don't have much idea about lighting.
My requirement is to show all nearby accounts on google map. 

Apex Class

public class accController { 
    @AuraEnabled
    public static List<Account> getAccounts() {
        return [select id, Account.BillingStreet, Account.BillingPostalCode, Account.BillingCity,sandbox__Geolocation__Longitude__s,sandbox__Geolocation__Latitude__s, Account.BillingState, Account.BillingCountry from Account where sandbox__Geolocation__Latitude__s != null];
 
    }
 
}
 
Component 

<aura:component implements="force:appHostable" controller="accController">
 
    <ltng:require styles="/resource/leaflet/leaflet.css" />   
    <ltng:require scripts="/resource/leaflet/leaflet.js"
             afterScriptsLoaded="{!c.jsLoaded}" />
 
    <div class="map" id="map"></div>
 
</aura:component>
 
Controller 

({
jsLoaded: function(component, event, helper) {
    debugger;
    var accs = component.get("c.getAccounts");
                debugger;
    accs.setParams({
        "sandbox__Geolocation__Longitude__s": component.get("v.sandbox__Geolocation__Longitude__s")
    });
    debugger;
    setTimeout(function() {

/*Not Working-- this line */
        // var map = L.map('map', {zoomControl: false}).setView([sandbox__Geolocation__Longitude__s,sandbox__Geolocation__Latitude__s], 14);
       
var map = L.map('map', {zoomControl: false}).setView([25.509637,71.091645], 14);
        L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
            {
                attribution: 'Tiles © Esri'
            }).addTo(map);
 
        // Add marker
        L.marker([sandbox__Geolocation__Longitude__s,sandbox__Geolocation__Latitude__s]).addTo(map)
            .bindPopup('Simplion Technologies Pvt Ltd');
        });
}
})
 
The problem I am facing is to get dynamic longitude and latitude values from account object. As you can see I have commented out the line. 
If I hardcode the longitude (i.e. 25.509637) and latitude (i.e. 71.091645) values then it works fine for me. 
So I want to make this dynamic. So that it takes automatically longitude and latitude value from the account records.
If anyone can help me on this or give some ideas. It will be really helpful.
 
 
 
Best Answer chosen by Rajiv
Mohith Kumar ShrivastavaMohith Kumar Shrivastava
There is whole tutorial in below link

http://ccoenraets.github.io/getting-started-lightning-components/