+ Start a Discussion
Ola BamideleOla Bamidele 

changing Icon Used on Map

Hi everyone, 

I have this code that displays a particiular location of a account on a map however, I have been trying to change the map icon to something else but the only example online are examples where the location is fixed in the script - whereas i am pulling the location from a field in Salesforce. 

I made been tryng apply the example to mine but i have had no luck as of yet. 

So please if anyone know how I can change the map icon, please let me know!

My code:
({
    jsLoaded: function(component, event, helper) {
        var map = L.map('map', {zoomControl: false, tap: false}).setView([37.784173, -122.401557], 14);
        L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
            { 	
                attribution: 'Tiles © Esri'
            }).addTo(map);
        component.set("v.map", map);
        
},
    
accountsLoaded: function(component, event, helper) {
        // Add markers
        var map = component.get('v.map');
        var accounts = event.getParam('accounts');
        for (var i=0; i<accounts.length; i++) {
            var account = accounts[i];
            var latLng = [account.Location__Latitude__s, account.Location__Longitude__s];
            L.marker(latLng, {account: account}).addTo(map)
            // To display account name and status in the text balloon
            .bindPopup(account.Name);
            
          }  
    },
    
   accountSelected: function(component, event, helper) {
        // Center the map on the account selected in the list
        var map = component.get('v.map');
        var account = event.getParam("account");
        map.panTo([account.Location__Latitude__s, account.Location__Longitude__s]);        		

    }
})

Thanks very much!