![]() ![]() The rest of the php code is not a problem, but that line (even commented) breaks everything. ![]() (window, "load", initMap) Īfter a some time of trying things I noticed that the problem seems to be when I add this line //var json_data = "" Map = new (document.getElementById('map'), , But as soon as I change the extension to php, it breaks. But in response to your concern about the place to put this code, it really doesn't matter where in the functions.php you put this code. However, I want my code to run the query that produces the GeoJSON data, and I know how to do that in php. You are using wpenqueuescripts() in the proper way, however you are enqueuing everything in the footer, and re queuing jQuery (which is not a good practice, you could use jquery-migrate instead). You can rate examples to help us improve the quality of examples. These are the top rated real world PHP examples of etpbenqueuegooglemapsscript extracted from open source projects. I'm using Xampp to load Apache and view files on my browser. PHP etpbenqueuegooglemapsscript - 3 examples found. html the map shows up just fine, and it shows the data I want to see (a Linestring). Right now the plugin injects the Google Maps API script after the page is loaded. Looks like the behaviour's changed in the latest version of WordPress - the above doesn't work (but I'll leave it for people on legacy versions).I've been trying to load some GeoJSON data into a map, using Google Maps API. '&sensor=false' įor what it's worth, our (working) code is: wp_register_script('googlemaps', ''. How To Enable Enqueue Google Maps Script Divi Theme WordPress WebsiteHow To Disable Enqueue Google Maps Script Divi Theme WordPress WebsiteDisable this optio. ![]() I suspect your problem is that it's being double-encoded, as you already have &. I've got something similar in our code, and it's working fine (even encoded as &). However, I want my code to run the query that produces the GeoJSON data, and I know how to do that in php. Im using Xampp to load Apache and view files on my browser. I could of course just get the function to echo the HTML as a script tag, but I'd rather use the wp_enqueue_script system if possible. html the map shows up just fine, and it shows the data I want to see (a Linestring). It is definitely not fine from Google's point of view. I saw a bug of this kind mentioned in the WordPress trac system: but it was dismissed as invalid, and the admin responding to the request showed somehow that the "&" approach was fine. First of all enqueue the Google Maps API js in the right way. When I type it directly into browser address bar with "&sensor=false" at the end, it loads fine. This actually makes the Google server reject the request. WordPress is escaping the "&" to "&". Wp_enqueue_script('google-maps', $gmaps_url, NULL, NULL) $key = get_option('google_maps_api_key') Commonly the maps will be embedded within a wordpress post that has images that are styled. The actual API key is configured in an options page I am creating a maps plugin for Wordpress that uses Google Maps JS API V3. Detecting request type in PHP (GET, POST, PUT or DELETE) 1116. Google Maps API file is enqueue this way. You can specify multiple pin locations and is a visual and useful. I'm trying to load the Google Maps API using the following syntax: add_action('admin_enqueue_scripts', 'load_google_maps') Loading Google Maps API with wpenqueuescript. Hi, I have an issue with Google Maps and Complianz (everything works fine when the plugin is desactivated). The Divi Map Module is an easy way to display an interactive Google map on your website. ![]()
0 Comments
Leave a Reply. |