Mapbox API key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • f522
    New Member
    • Sep 2018
    • 15

    #1

    Mapbox API key

    Hi!

    I saw this website(http://onrails.eu/viewtopic.php?f=8&t=44) that I can create a mapbox api key for TSRE instead of google,
    but the instruction is very shady and incomplete.

    Can someone write step by step how to get this thing?
  • rdayt
    1000 Post Veteran

    • Nov 2007
    • 1291
    • SW MO
    • ORTS

    #2
    It's really easy.
    Go to mapbox.com and create an account. It's free.
    Log in and go to account->tokens and click on create token.
    Copy the token and open your TSRE Settings.txt.
    Enter it in like this,
    imageMapsUrl = http://api.mapbox.com/v4/mapbox.satellite/{ (clipped)
    Save and you're done.

    Randy

    Comment

    • f522
      New Member
      • Sep 2018
      • 15

      #3
      Thanks but where can I find the lon, lat, zoom and res?

      Comment

      • rdayt
        1000 Post Veteran

        • Nov 2007
        • 1291
        • SW MO
        • ORTS

        #4
        I use Google Earth.
        Go where you want. It'll give you the coordinates.
        When you use it in TSRE there's a dropdown to choose a couple different resolutions.
        There is no zoom.

        Randy

        Comment

        • eric
          9500 Post Veteran and Administrator



          • Dec 2002
          • 9583
          • NS MP245.4 CNO&TP South District
          • English, SQL
          • General

          #5
          FYI, the MapBox API format has changed. Here's the new format to go in the Settings.txt:


          imageMapsUrl = https://api.mapbox.com/styles/v1/mapbox/satellite-v9/static/{lon},{lat},17/{res}x{res}?access_token=yourtoken


          (yourtoken will be considerably longer.... and goes after the = sign)
          The 17 after the lon/lat is the zoom -- you can also do 18 for a higher resolution
          Last edited by eric; 04-26-2023, 18:33.
          If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

          Comment

          • CSRX
            13500 Post Veteran



            • Oct 2005
            • 13646
            • Lincoln, ME
            • English
            • ORTS

            #6
            Well, since updating to the new mapbox... this is rather, annoying....

            -Shawn K-
            MEC Mountain Subdivision - Trackwork 70%, Scenery 35%
            ​

            Comment

            • kapitaen
              Senior Member

              • May 2010
              • 331
              • Germany
              • German + a little bit English
              • MSOR

              #7
              The zoom has changed and must be entered manually.
              Standard Terrain
              Raster Image Z18 =17
              Raster Image Z17 =16
              Distance Terrain
              Raster Image Z18 =13
              Raster Image Z17 =12
              Example: Standard Terrain Raster Image Z18 =17
              Code:
              imageMapsUrl = https://api.mapbox.com/styles/v1/mapbox/satellite-v9/static/{lon},{lat},17/{res}x{res}?access_token=
              +YOUR_MAPBOX_ACCESS_TOKEN

              Comment

              • CSRX
                13500 Post Veteran



                • Oct 2005
                • 13646
                • Lincoln, ME
                • English
                • ORTS

                #8
                Originally posted by kapitaen
                The zoom has changed and must be entered manually.
                Standard Terrain
                Raster Image Z18 =17
                Raster Image Z17 =16
                Distance Terrain
                Raster Image Z18 =13
                Raster Image Z17 =12
                Example: Standard Terrain Raster Image Z18 =17
                Code:
                imageMapsUrl = https://api.mapbox.com/styles/v1/mapbox/satellite-v9/static/{lon},{lat},17/{res}x{res}?access_token=
                +YOUR_MAPBOX_ACCESS_TOKEN

                That did the trick, thank you so much sir!
                Now the question, which do you recommend, Z17 or Z18 for resolution?
                -Shawn K-
                MEC Mountain Subdivision - Trackwork 70%, Scenery 35%
                ​

                Comment

                • eric
                  9500 Post Veteran and Administrator



                  • Dec 2002
                  • 9583
                  • NS MP245.4 CNO&TP South District
                  • English, SQL
                  • General

                  #9
                  I've been using Z17 with both Google and MapBox with fairly good results.

                  Hopefully Goku is aware and can change the structure for the settings.txt file he includes in the download package...
                  If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                  Comment

                  • yellowdog
                    1500 Post Veteran



                    • Nov 1999
                    • 1586
                    • .
                    • MSOR

                    #10
                    I never have been able to get this to work. I'm following the above, as well as the 2018 Train Simulator Route Explorer guidebook. I put this in settings:

                    imageMapsUrl = https://api.mapbox.com/styles/v1/mapbox/satellite-v9/static/36.43129885,-82.46999068,17/{res}x{res}?access_token=xxxx

                    (where xxxx is my token from Mapbox and lat/long are a random place on the Kingsport Sub). I entered "17" as indicated above for zoom. But I still don't see what to do with either {res} entries. It does seem to pull up the lat/long when I load the map. But I only get it to load with the OSM Vector option, which is not a satellite image--it's more like the turn-by-turn driving map image in basic gps directional software. Selecting either Raster17 or Raster18 produces a blank box (either white or black, depending on if I reverse it). In the Mapbox settings, I picked the default Styles: Tiles, Styles:Read, Fonts:Read, DataSets:Read, Vision:Read.

                    I should also mention I'm not editing the KP Sub. I created a new test route to play around with this stuff.

                    What am I missing?

                    I did get height to work.

                    Comment

                    • CSRX
                      13500 Post Veteran



                      • Oct 2005
                      • 13646
                      • Lincoln, ME
                      • English
                      • ORTS

                      #11
                      This is the only portion that needs to be exactly the same.
                      "{lon},{lat},17/{res}x{res}"
                      You don't need to add the lon or lat coordinates in place, or the res size. This is done automatically by mapbox. From there you can choose Raster17 or Raster18 (I use Raster17 mostly), and it should load up fine.
                      -Shawn K-
                      MEC Mountain Subdivision - Trackwork 70%, Scenery 35%
                      ​

                      Comment

                      • yellowdog
                        1500 Post Veteran



                        • Nov 1999
                        • 1586
                        • .
                        • MSOR

                        #12
                        Ah, that did it, thanks!

                        Comment

                        • abhisheksharma
                          New Member
                          • Feb 2017
                          • 1

                          #13
                          I am searching this from many months but now today my wish is complete now... because google API key is too costly so I want to use mapbox for route making but I don't know about format ...please admin of tsre consider it and changed the format of mapbox in tsre so it helps everyone like me...
                          Last edited by abhisheksharma; 02-24-2024, 13:01.

                          Comment

                          • eric
                            9500 Post Veteran and Administrator



                            • Dec 2002
                            • 9583
                            • NS MP245.4 CNO&TP South District
                            • English, SQL
                            • General

                            #14
                            You can use either Google or MapBox. The formats are slightly different, but work just the same.

                            .I've literally downloaded well over 1000 square miles of terrain images for my routes from Google. Many people shy away from having to have a credit card on file, but I don't think in those ten years, I've ever downloaded enough imagery to where I've had to pay. The trick is to spread it out over several months.
                            If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                            Comment

                            • eric
                              9500 Post Veteran and Administrator



                              • Dec 2002
                              • 9583
                              • NS MP245.4 CNO&TP South District
                              • English, SQL
                              • General

                              #15
                              Quick revisit on this....

                              Starting in v8.003 of TSRE, you'll be able to select the Z17 and Z18 again for Mapbox, and go back to the "old" MapBox API URL.
                              If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, or items available in our library, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                              Comment

                              Working...