Asynchronous enqueue of the Google Maps API
Add this to your URL when calling the google API: &loading=async
Add this to your URL when calling the google API: &loading=async
Use wp_enqueue_script from your PHP code to register and enqueue a script. WordPress will then handle automatically adding the required script tags at the right place and you’ll be able to instantiate and use the API from your javascript. E.g. (untested, check the docs for your use case) wp_enqueue_script(‘googlemaps’, ‘https://maps.googleapis.com/maps/api/js?&key=KEY’);
How to do google maps with own markers, text pop-ups on specific locations with clickabkle links
Problem 1 neither I see the function initMap in the footer. This is because of the action here: add_action(‘wp-footer’, [$this, ‘init_google_map’]); There is no wp-footer hook. You probably intended to use wp_footer: https://developer.wordpress.org/reference/hooks/wp_footer/ Though keep in mind this isn’t guaranteed to be in a footer, just at the end of the HTML document before the … Read more
While you can’t obfuscate/hide the code, you can restrict access by domain: https://developers.google.com/maps/api-security-best-practices
WordPress – Generate Longitude Latitude Map into Page
I want to lists posts in wordpress to nearest location entered by the user
I think the issue that the Google maps API isn’t loading correctly. You need to make sure that the both jQuery and Google maps API are being loaded. https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js http://maps.google.com/maps/api/js It can be any recent version of jQuery, and from any source. Assuming that your jQuery function is contained within your google-maps-address.js file the following … Read more
Google API’s now requires API key for new domains, you should create an API key as per instructions here: https://developers.google.com/maps/documentation/javascript/get-api-key and edit the line in the plugin that loads the Google Maps API to include your key as the value of a ‘key’ parameter. Wherever you find one of these: “https://maps.googleapis.com/maps/api/js“ or “http://maps.googleapis.com/maps/api/js” in the … Read more
It might be that you haven’t set your Google Maps API key. Or, if you have already set an API key then it might be due to any restrictions that you may have set for the API key such as restricting it to a specific domain. You can obtain a Google Maps API key from … Read more