Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Integrate mapbox map

Integrate mapbox map

Scheduled Pinned Locked Moved General Discussion
5 Posts 2 Posters 936 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • WalkerW
    WalkerW
    Walker
    wrote on last edited by Walker
    #1

    Hi there,
    I want to integrate a mapbox map into a page.

    I have tried a lot but I can't get it done.

    Here is the way I tried to do it.
    (here is also a simple instruction from mapbox: https://www.mapbox.com/install/javascript/cdn-install/)

    In the custom head area I copied this:

    <script src='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css' rel='stylesheet' />
    
    <script>
      mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
      var map = new mapboxgl.Map({
        container: 'map',
        style: 'mapbox://styles/mapbox/streets-v11'
      });
    </script>
    

    In the specific page where the map should show up, I inserted a html with the following:

    <div id='map' style='width: 400px; height: 300px;'></div>
    

    Thats it, but nothing will appear on the site.
    ––––
    When I insert the Div into the custom head area it works, but then the map is globaly on every page.

    I think this should be not too complicated.
    If anybody can help I would be very happy.

    Thanks

    1 Reply Last reply
    0
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2

      insert this:

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

      into "html at bottom"

      WalkerW 1 Reply Last reply
      0
      • arminunruhA arminunruh

        insert this:

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

        into "html at bottom"

        WalkerW
        WalkerW
        Walker
        wrote on last edited by
        #3

        Hi @arminunruh,
        thanks for the answer.

        I changed the code, but didn't work.

        I have the feeling the problem is the div which I insert into the certain page. Here is a picture how I did it.
        dfdf.png

        The interesting part is, when I put all the code I posted above into the custom head area (also the "div id=map ...") then the map appears. But on every page and always ...

        1 Reply Last reply
        0
        • arminunruhA
          arminunruhA
          arminunruh
          Global Moderator
          wrote on last edited by arminunruh
          #4

          well the div markup is wrong too

          <div id="map"></div>

          u're missing a >

          why don't u try and do it exactly like they did in the tutorial?
          they didnt put all of the javascript in the <head>.

          they put part of it after the <div id="map"></div>

          if u do so make sure to activate compatibility mode in lay options (all the way at the bottom)

          WalkerW 1 Reply Last reply
          0
          • arminunruhA arminunruh

            well the div markup is wrong too

            <div id="map"></div>

            u're missing a >

            why don't u try and do it exactly like they did in the tutorial?
            they didnt put all of the javascript in the <head>.

            they put part of it after the <div id="map"></div>

            if u do so make sure to activate compatibility mode in lay options (all the way at the bottom)

            WalkerW
            WalkerW
            Walker
            wrote on last edited by
            #5

            Thanks a lot for you time!

            Now it works. 😘

            1 Reply Last reply
            1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better šŸ’—

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Online Users
            R
            robertobarbes
            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
            laytheme.com
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Search