-
AuthorPosts
-
June 30, 2021 at 11:19 am #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.
PaoloJuly 1, 2021 at 11:34 am #1308295Hey 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,
IsmaelJuly 1, 2021 at 5:58 pm #1308377Hi 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 thingsI 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, 5 months ago by Paolo_Gentile.
July 4, 2021 at 12:13 am #1308611Hi,
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:
Then you should go to this page to learn how to customize your MapBox map.
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,
MikeJuly 5, 2021 at 11:12 am #1308752Hi Mike!
Thanks a lot for your help! 😊Suggestion: I think to have a MapBox Element in Enfold would be great!
Best regards,
PaoloJuly 5, 2021 at 4:55 pm #1308812Hi,
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 ShannonJuly 5, 2021 at 4:59 pm #1308816Hi Jordan,
it’s ok, you can close.Best regards,
PaoloJuly 5, 2021 at 5:05 pm #1308819Hi,
If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Insert Mapbox in a Contact page…’ is closed to new replies.