spongeboob
Forum Replies Created
-
Forum: Plugins
In reply to: [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map] Ajax Powered ThemeYeah, it would be great if the plugin could be more ajax friendly. It’s the best google maps plugin i’ve found.
I’m using theme with custom ajax controller, but it should be same as any other ajax powered theme. Basically it fetches new page via ajax and replace the content. Scripts are to be added an run in js like this:
var $scripts = $ajaxResponse.find('#content script'); $scripts.each(function() { var scriptText = $(this).html(); if ('' !== scriptText) { var script = document.createElement('script'), textNode = document.createTextNode(scriptText); script.appendChild(textNode); contentNode.appendChild(script); } else { $.getScript($(this).attr('src')); } });Solution for the plugin could be adding the scripts along with the map into the content, or have there an option checkbox in admin for ajax powered themes for that. I’ve seen it in some other plugin.
Forum: Plugins
In reply to: [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map] Ajax Powered ThemeAfter digging in the code for a while i give it up 🙂
Tried solution like this:
First i checked if content
has_shortcode($content, 'wpgmza'), then with regex search for the map id and called the plugin shortcode functionwpgmaps_tag_basic($id);and then fromglobal $wp_scriptsadded an run the scripts and the localization properties in the content.It does partly worked, but for me it’s too much hairy solution 🙂 I guess the plugin is not much ajax friendly written, but maybe I’m doing it wrong as well….)
Forum: Plugins
In reply to: [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map] Ajax Powered ThemeNope, because google maps api and the wpgmaps.js scripts are not loaded.
It does work when I load a page where is a google map as first, then the scripts and the whole plugin are loaded, then when I change a page via the ajax powered theme, I can call
InitMap();in my javascript and the map is ok.But if I load a page where is no google map, the scripts are not loaded, and then when i go to the page where is a google map, there is a blank space.
The ajax powered theme can add and run scripts placed in the content, but not in header or footer.
So i probably need to load the scripts somehow via ajax with condition
has_shortcode($content, 'wpgmza'), or at the first load of wordpress i guess even if there is no google map on the page. But there is also the localization o_OI’m more into front-end, so I’m quite short how to deal with the back-end / plugin…
Forum: Plugins
In reply to: [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map] Ajax Powered ThemeI ok with the JS thing, if I’am right. But i don’t know how to init the plugin on first load…