Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1308071

    Hello,
    I would like to insert a Mapbox in a “Contact” page like in the Enfold Theme Demo (kriesi.at/themes/enfold/pages/contact/), instead of Google Maps.
    I’ve created a free account in mapbox.com.
    Someone can help me, please? Thanks.
    Paolo

    #1308295

    Hey Paolo,

    Thank you for the inquiry.

    Do they provide an embed script or an iframe code? You should be able to insert the embed script in a text or code block element in the advance layout builder.

    Best regards,
    Ismael

    #1308377

    Hi Ismael,
    this is what they provide: http://www.mapbox.com/install/js/ ; but I don’t know what I must choose and so how to insert the respective codes in the “Code Block Element” of the Enfold Advanced Layout Builder.
    Sorry, but I’m not expert in these things

    I would like to use the “Google Maps Block Element” of the Enfold Advanced Layout Builder, but I can’t create a free “Google Maps API” because I don’t use the classic Credit Card (Google doesn’t accept other types of payement)…

    Best regards,
    Paolo

    • This reply was modified 3 years, 3 months ago by Paolo_Gentile.
    #1308611

    Hi,
    Thank you for your patience, and the link to your MapBox install instructions, first I would recommend using the Enfold Child Theme so you don’t lose the changes when you update the theme.
    Then add this code to the end of your functions.php file in Appearance > Editor:

    function install_mapbox(){
        ?>
    <script src='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.css' rel='stylesheet' />
        <?php
        }
    add_action('wp_head', 'install_mapbox');

    then add this to a code block on your page:

    <div id='map' style='width: 400px; height: 300px;'></div>
    <script>
    mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
    var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11'
    });
    </script>

    you will need to add your access token to replace this part of the code: YOUR_MAPBOX_ACCESS_TOKEN
    Then the default map will show:
    2021-07-03_011.jpg
    Then you should go to this page to learn how to customize your MapBox map.
    2021-07-03_012.jpg
    If you can’t create a free “Google Maps API” then you can’t use the Google Maps element, unfortunately we currently don’t have a MapBox element.

    Best regards,
    Mike

    #1308752

    Hi Mike!
    Thanks a lot for your help! 😊

    Suggestion: I think to have a MapBox Element in Enfold would be great!

    Best regards,
    Paolo

    #1308812

    Hi,

    That is perhaps an update that can be realized in the future. Did you need additional help with this topic or shall we close?

    Best regards,
    Jordan Shannon

    #1308816

    Hi Jordan,
    it’s ok, you can close.

    Best regards,
    Paolo

    #1308819

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Insert Mapbox in a Contact page…’ is closed to new replies.