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. However, I want my code to run the query that produces the GeoJSON data, and I know how to do that in php. This reply was modified 2 years ago by snippet24. However, I want my code to run the query that produces the GeoJSON data, and I know how to do that in php. Okey please correct me if I’m wrong all it takes is to add: wpgetscripttag ( array ( 'src' > 'RELATIVEPATH/FILE.js', 'defer' > true, ) ) alongside the usual wpenqueue script. This seems to do the trick with Divi builder hanging. And take your Google Map API Key out As this is already included in the WPgoogle maps Advanced Tab settings. Im using Xampp to load Apache and view files on my browser. If anyone is using the divi theme or builder Turn of the Enqueue Google Maps Script in the div options page. I'm using Xampp to load Apache and view files on my browser. html the map shows up just fine, and it shows the data I want to see (a Linestring). html the map shows up just fine, and it shows the data I want to see (a Linestring). 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', ''. I suspect your problem is that it's being double-encoded, as you already have &. Google Maps Platform gives apps the ability to include the features and functionality of Google Maps, such as displaying maps, retrieving place data. Detecting request type in PHP (GET, POST, PUT or DELETE) 1116. Instead of passing in an empty array to specify no dependencies for the script, the array contains a blank string. I've got something similar in our code, and it's working fine (even encoded as &). Loading Google Maps API with wpenqueuescript. First of all enqueue the Google Maps API js in the right way. 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. It is definitely not fine from Google's point of view. Right now the plugin injects the Google Maps API script after the page is loaded. 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. 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') ![]() The actual API key is configured in an options page ![]() Set Show Facebook Icon Enable to display the Facebook icon in Divi’s top and bottom bars. Set Use Google Fonts Enable to use the Google Fonts libraries within the Divi Builder. You can specify multiple pin locations and is a visual and useful. Set Enqueue Google Maps Script Enable for proper functioning of Divi Maps Modules. I'm trying to load the Google Maps API using the following syntax: add_action('admin_enqueue_scripts', 'load_google_maps') The Divi Map Module is an easy way to display an interactive Google map on your website.
0 Comments
Leave a Reply. |