• I’m trying to add a mapbox map to my site without using plugins.

    The map is similar to this https://jsfiddle.net/cogmg2v3/ and is working fine in JSfiddle or as a html file, but I don’t know how to run it in wordpress.

    I’ve tried to enqueue it using:

    function add_mapbox() {
      wp_enqueue_script('mapbox', 'https://api.tiles.mapbox.com/mapbox.js/v2.1.8/mapbox.js');
      wp_enqueue_style('mapbox_style','https://api.tiles.mapbox.com/mapbox.js/v2.1.8/mapbox.css');
      wp_enqueue_script( 'mapbox_map', get_stylesheet_directory_uri() . '/js/leaflet.js');
    }
    
    if(is_page( 24 ) ) add_action('wp_enqueue_scripts', 'add_mapbox');

    However the tiles are not loading, so I’m pretty clueless atm.

    I guess it should be pretty similar to adding a map from googlemaps etc. without plugins if someone has experience doing it.

  • The topic ‘Adding mapbox map without plugins’ is closed to new replies.