Reputation: 4386
I load the google map api and execute the init function initMap()
with the callback
parameter :
<script async="" defer="" src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxx&callback=initMap"></script>
I want to use an other script (js-rich-marker
) in order to create a custom marker (with css style).
I load :
script async="" defer="" src="https://raw.githubusercontent.com/googlemaps/js-rich-marker/gh-pages/src/richmarker-compiled.js"></script>
But initMap();
doesn’t work on page load :
ReferenceError: Can't find variable: RichMarker
(I know the script can work because i can update the map with a menu which update the map with AJAX and in this case it's working.).
I guess it is because the init function is executed before js-rich-marker
is fully loaded.
I’ve tried to call the init function when everything is loaded but it is still not ok.
document.addEventListener("DOMContentLoaded", function(event){
initMap();
});
$(window).load(function() {
initMap();
});
$(window).bind("load", function() {
// code goes here
});
How can i call a function one everything is loaded ?
Upvotes: 0
Views: 1238
Reputation: 243
window.document.onload= function(e){
}
window.onload = function(e){
}
and call next js-rich-marker example:
Upvotes: 1