WordPress.org

Ready to get started?Download WordPress

Forums

Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps)
[resolved] do_shortcode JS and CSS files (4 posts)

  1. Pepperbase
    Member
    Posted 1 year ago #

    Hi,

    On mobile devices I would like to do an Ajax call to show a map. The map is showing, but it only shows 'map is loading' message. I use do_shortcode to show the map, but because do_shortcode is not in the template the JS and CSS files are not loaded. How can I load the appropiates JS and CSS files manually?

    This code is not working:

    add_action('wp_enqueue_scripts', 'my_scripts_method');
    function my_scripts_method() {
    
    	if((is_home()) || (is_page(array(16,19,21,23,25)))){
    	wp_deregister_script( 'ai1ec_requirejs' );
    	}
    
    	if ('ai1ec_event' !== get_post_type() && is_single()) {
    	global $wp_styles;
    	$plugin_version = get_option('leafletmapsmarker_version');
    	wp_register_style('leafletmapsmarker', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.css', array(), $plugin_version);
    	wp_enqueue_style('leafletmapsmarker');
    	wp_register_style('leafletmapsmarker-ie-only', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.ie.css', array(), $plugin_version);
    	wp_enqueue_style('leafletmapsmarker-ie-only');
    	$wp_styles->add_data('leafletmapsmarker-ie-only', 'conditional', 'lt IE 9');
    
    	wp_register_script( 'leafletmapsmarker', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.js', array('leafletmapsmarker-googlemaps-loader', 'jquery' ), $plugin_version, true);
    	wp_register_script( 'show_map', LEAFLET_PLUGIN_URL . 'inc/js/show_map.js', array('leafletmapsmarker' ), $plugin_version, true);
    	wp_register_script( 'leafletmapsmarker-googlemaps-loader', 'https://www.google.com/jsapi?key='.$google_maps_api_key, array(), 3.7, true);
    }
    }

    Is there anything else I should do to make it work?

    http://wordpress.org/extend/plugins/leaflet-maps-marker/

  2. RobertHarm
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Pepperbase,

    I am not quite sure, but you could try changing the following settings under Misc:

    Where to insert Javascript files on frontend?
    and
    Support for conditional css loading

    Perhaps changing the default value here could help.
    best,

    Robert

  3. Pepperbase
    Member
    Posted 1 year ago #

    Hi,

    Yes that works, but I want to use Ajax on mobiles for performace reasons. Loading JS in the header and CSS on all pages wouldn't help :-)

    Anyway, I decided to open a new page and send the marker via the url.

    Thanks.

  4. RobertHarm
    Member
    Plugin Author

    Posted 1 year ago #

    OK (marking this topic as resolved)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic