I have this webshop that is currently deployed, and it is based on WordPress. I have added a functionality where-in if the administrator types in the address, the Map will be shown. So far so good, things are doing great.
However, I noticed that whenever I add this:
wp_enqueue_script('googlemap', 'http://maps.google.com/maps/api/js?sensor=false', array(), false, true);
which obviously is the Google Map js, the drag and drop functionality of the WordPress Admin (most obviously the Widget area) doesn’t work. I tried commenting this line, and voila, drag and drop of widgets is back, but of course no Google Maps.
Have you encountered this as well? How did you go about this? Currently I am operating my admin page via the non-javascript version of Widgets. Workable, but not ideal.
This may help you as it’s just fixed my issue.
I’ve loading google maps same as you but in my own js file I have:
That way it isn’t loaded on pages without a #gmap element
Try:
Edit: Please comment if this is being used in the admin panel and I’ll find a workaround; the above code only queues the googlemap script in the frontend.
You can control with extreme precision the page of the admin panel where a script must be loaded. The first think you have to consider is that: if the DOM element is not found, the maps API generate the error “a is undefined”. So you must load the API in the right page of the admin panel.
I use the following script to load the GMaps API in a specific custom post type edit screen: