Support » Plugin: Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps) » do_shortcode JS and CSS files

  • Resolved Pepperbase



    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_register_style('leafletmapsmarker-ie-only', LEAFLET_PLUGIN_URL . 'leaflet-dist/', array(), $plugin_version);
    	$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', ''.$google_maps_api_key, array(), 3.7, true);

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author RobertHarm


    Hi Pepperbase,

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

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

    Perhaps changing the default value here could help.



    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.


    Plugin Author RobertHarm


    OK (marking this topic as resolved)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘do_shortcode JS and CSS files’ is closed to new replies.