Reputation: 522
getting error in java script all things works normal then why give this error, i won't able to run the code which is written below this and this is google function which is important to use so how can i remove or is there any other way to solve the error
//Error is given on this line
google.maps.event.addDomListener(window, 'load', initGoogleMap);
//because of error this code not works
google.maps.event.addListener(marker, 'click', function() {
if(!marker.open){
infoWindow.open(map,marker);
marker.open = true;
}
else{
infoWindow.close();
marker.open = false;
}
google.maps.event.addListener(map, 'click', function() {
infoWindow.close();
marker.open = false;
});
});
Upvotes: 1
Views: 539
Reputation: 15603
google.maps.event.addDomListener(window, 'load', initGoogleMap);
Above code is for calling the function initGoogleMap
at the time of window load. So there will be following reason of giving the error:
initGoogleMap
you have not defined.To resolve this follow the below statements:
onload = initGoogleMap()
in the body tag. After that your body tag will be like this:<body onload = initGoogleMap()>
Hope it will help you. If you have any query, asked me.
Upvotes: 1