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
Bithyzis DimitriosBithyzis Dimitrios 

Build an Account Geolocation App - Error despite completing the trail

Hello developers

Need to admit that I have no developer knowledge and I thought that this "project" was a good idea...

Despite the project showing as complete in trailhead I have encountered the following error.

The trailhead section - use events to center the app is working when it is running on the browser but when I include the click event handler to the markers
L.marker(latLng, {account: account}).addTo(map).on('click', function(event) {
    helper.navigateToDetailsView(event.target.options.account.Id);
});


Thus changing the AccountMapControler from

({
    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);
        }  
    },
    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]);
    }
})


To the following

({
    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).on('click', function(event) {
    helper.navigateToDetailsView(event.target.options.account.Id);
});
        }  
    },
    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]);
    }
})
When clicking on a marker from within the web browser tab from where I am running the application, I receive the following error

Uncaught TypeError: Cannot read property 'setParams' of undefined throws at https://cunning-otter-goe27l-dev-ed.lightning.force.com/c/components/c/AccountMap.js:40:15

While if I open the tab in the salesforce 1 and salesforce I receive the below error

Error in $A.getCallback() [helper.reportErrorSafely is not a function]
Object.loadContent()@https://cunning-otter-goe27l-dev-ed.lightning.force.com/components/laf/pageHost.js:18:417
Object.eval()@https://cunning-otter-goe27l-dev-ed.lightning.force.com/components/laf/pageHost.js:14:374


Any help will be much appreciated

With regards
Dimitrios
Best Answer chosen by Bithyzis Dimitrios
Martha VMartha V
Check out the following post, I hope it helps... sorry I am at a computer that doesn't allow copy and paste, so I can't post the link, but if you do a Google search with the following words you will find the post:

ERROR WHEN TESTING FOR TRAILHEAD: BUILD AN ACCOUNT GEOLOCATION APP

 

All Answers

Martha VMartha V
Check out the following post, I hope it helps... sorry I am at a computer that doesn't allow copy and paste, so I can't post the link, but if you do a Google search with the following words you will find the post:

ERROR WHEN TESTING FOR TRAILHEAD: BUILD AN ACCOUNT GEOLOCATION APP

 
This was selected as the best answer
Bithyzis DimitriosBithyzis Dimitrios
Thank you Martha for the advise.
I runned a Google Search for - Error when testing for Trailhead: Build an Account Geolocation App

Went through the first post - https://developer.salesforce.com/forums/?id=9060G0000005gDwQAI

Which suggest to clear cookies - clear cache and the thing worked as charm...