Support » Plugin: Simple Google Maps Shortcode » shortcode not displaying properly

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator mordauk

    (@mordauk)

    You will probably need to load the javascript manually. Are you familiar with how to do that?

    not really but I can take directions 😀

    Moderator mordauk

    (@mordauk)

    Use Pluginception to create a new plugin: https://wordpress.org/plugins/pluginception/

    After creating a plugin, add this code to it:

    function custom_pw_map_load_scripts() {
    	wp_enqueue_script( 'google-maps-api', '//maps.google.com/maps/api/js?sensor=false' );
    }
    add_action( 'wp_enqueue_scripts', 'custom_pw_map_load_scripts' );

    Unfortunately didn’t do anything, the page embedded shortcode displays properly while the form embedded one is not:
    http://okamotokitchen.com/map-test/

    My guess is that the JS code generated by the plugin doesn’t run because it’s embedded into a list item. Here is the source of the form embedded one:

    <div class='gform_body'><ul id='gform_fields_9' class='gform_fields top_label form_sublabel_below description_below'><li id='field_9_1' class='gfield gfield_html gfield_html_formatted gfield_no_follows_desc field_sublabel_below field_description_below' >		<div class="pw_map_canvas" id="pw_map_5637add0310df" style="height: 400px; width: 100%"></div>
    	<script type="text/javascript">
    		var map_pw_map_5637add0310df;
    		function pw_run_map_pw_map_5637add0310df(){
    			var location = new google.maps.LatLng("34.156972", "-118.437235");
    			var map_options = {
    				zoom: 15,
    				center: location,
    				scrollwheel: 1,
    				disableDefaultUI: 0,
    				mapTypeId: google.maps.MapTypeId.ROADMAP
    			}
    			map_pw_map_5637add0310df = new google.maps.Map(document.getElementById("pw_map_5637add0310df"), map_options);
    			var marker = new google.maps.Marker({
    			position: location,
    			map: map_pw_map_5637add0310df				});
    		}
    		pw_run_map_pw_map_5637add0310df();
    	</script>
    	</li>
    </ul></div>

    Nobody has any ideas?

    Moderator mordauk

    (@mordauk)

    If you move it outside of a list item, does it work?

    Yes it does, it’s what I’ve been trying to say in the original post. Here’s the link showing the upper one (outside the list) working while the lower one (inside the list) not working:

    http://okamotokitchen.com/map-test/

    Thanks!

    Still no ideas? I think what needs to happen is to have the JS removed from the plugin and added to the page first, but not sure how to achieve that due to the PHP intertwined in it…

    Moderator mordauk

    (@mordauk)

    I’m sorry but this is beyond the scope of what I can assist with at this time.

    Loading the JS globally should resolve it.

    Tried that already by modifying the plugin to load the JS in the footer of WordPress but to no avail…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘shortcode not displaying properly’ is closed to new replies.