Ask Search:
Colby JuarezColby Juarez 

Account Geolocation marker colors

I am working on a project where I have pulled in the account, geolocations for billing lat/ long, as well as a picklist field that I want to color by picklist icon. Any help would be greatly appreciated
 
// Get all Accounts, plot as Markers by package type
                for (var i = 0; i < accounts.length; i++) {
                    if (accounts[i].BillingLatitude !== null && accounts[i].BillingLongitude !== null ) {
                        let dynIcon;


// Enterprise
                        if (accounts[i].Package__c === 'Enterprise'){ dynIcon = orangeIcon }
                         // Pro
                        if (accounts[i].Package__c === 'Pro'){ dynIcon = yellowIcon }
                         // Advanced
                        if (accounts[i].Package__c === 'Advanced'){ dynIcon = violetIcon }
                         // Core
                        if (accounts[i].Package__c === 'Core'){ dynIcon = grayIcon }
                         // 750
                        if (accounts[i].Package__c === '750'){ dynIcon = blackIcon }
                         // Legacy
                        if (accounts[i].Package__c === 'Legacy (CG)'){ dynIcon = blueIcon }

                        // Fallback
                        if (accounts[i].Package__c !== 'Enterprise'){ dynIcon = greenIcon }

 
Best Answer chosen by Colby Juarez
Bishwambhar SenBishwambhar Sen
May be use a switch instead of so many if statements. Use CSS classes for the different colored icons. Set the CSS class dynamically based on the Package.

Let me know if this helps!

All Answers

Bishwambhar SenBishwambhar Sen
May be use a switch instead of so many if statements. Use CSS classes for the different colored icons. Set the CSS class dynamically based on the Package.

Let me know if this helps!
This was selected as the best answer
Colby JuarezColby Juarez
Ty for the reply Bishwambhar I had a ! in the code that wasn't needed.