Wednesday, December 9, 2015

How to resolve Google Maps and jQuery conflict

If Google Maps and jQuery are running in the same page of an application.
There might be conflicts and the Google Maps is not working sometimes.

To resolve this problem, just need to replace the following line

<script src="https://maps.googleapis.com/maps/api/js?sensor=false">

to the function below:

<script>
function loadScript() {
 var script = document.createElement('script');
 script.type = 'text/javascript';
 script.src = '//maps.googleapis.com/maps/api/js?sensor=false';
 document.body.appendChild(script);
}
$(document).ready(loadScript());
</script>


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...