Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
I am on the last step of the Trailhead Account Geolocation project and I get the following error:

User-added image

Here is the code from the AccountMapController-- What did I do wrong?

({

      jsLoaded: function(component, event, helper) {

         setTimeout(function() {

            var map = L.map('map', {zoomControl: 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]);

      }

})
13 answers
  1. Jan 13, 2016, 6:21 PM
    It doesn't looks like you may have forgotten some brackets or commas. Try pasting this in. I fixed a few things for you.

     

    ({

    jsLoaded: function(component, event, helper) {

    setTimeout(function() {

    var map = L.map('map', {zoomControl: 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]);

    }

    })

    Jeff Douglas

    Trailhead Developer Advocate
Loading
0/9000