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
michael  limmichael lim 

Lightning function fires twice when component added to Home screen and use tab navigation

I added the AccountLocator component from the  Build an Account Geolocation App trailhead project to my Home tab. I was getting an error with Leaflet.js so I moved the map creation code to the accountsLoaded function in AccountMapController.js.

Everything works OK when I first view the Home page, the accountsLoaded function runs one time. I can click refresh over and over and it works OK.
When I click another tab then go back to Home tab, the accountsLoaded function fires two times. This is causing me an error because the second time it tries to create the map that is already there. I get this error:
Uncaught Action failed: c$AccountMap$controller$accountsLoaded [Map container is already initialized.]

I'm using a Winter 17 dev org.

Thanks
Michael