I'm working with some project where I must use Angular. It's my first contact with this framework so I can make some mistakes.
I created function initMap()
which was called by Google Maps API callback (parameter &callback=initMap
in <script src="..">..
when I call for Google API's file).
My function initMap()
waiting for bag
variable values - it's global variable which contains cities which I want to use as markers. I know that it's really bad practice, but I spend a lot of time to get data from Angular scope - but I'm noob and I can't do it. Let's move on - when I receive data I'm creating new object via
var map = new google.maps.Map(document.getElementById('map'), mapOptions)
After that I'm waiting for idle
event and then I put markers on my map.
google.maps.event.addListenerOnce(map, 'idle', function() {
// Put markers
});
And here is a magic - SOMETIMES map isn't load. I receive gray box, Google logo in bottom-left corner and nothing more. When I put console.log(..)
in this listener I receive in console my log message.
When I do hard refresh (for example Ctrl + F5
) then everything is working fine (always).
My first idea is to remove defer
from script
tag (because in FireBug Network I can see very long load analitycs script) - but it doesn't help me.
And really please - don't spam with comments like "noob,don't use global variables". If it can't help me - please don't do a mess.
Regards