Mapbox base layer

JanB9 years ago

Hi.
Following instructions from https://www.traccar.org/forums/topic/can-you-help-me-with-own-maps/, I tried to set a Mapbox map as base layer. I included the access token parameter in the url (needed for use Mapbox API).
Problem is that only a blank map is displayed.
¿Could be a compatibility issue between Traccar and Mapbox?
Thank you in advance for any help you can provide.

Anton Tananaev9 years ago

Check browser developer tools. Are there any errors or warnings there?

JanB8 years ago

Hi, thanks for the reply.
Following your suggestion, first I tried the mapbox url without the access token parameter (you know, the map url without the "?access_token=..." at the end). In this case, the browser developer tools console shows that Traccar tries to get the tiles, but a 401 error (unauthorized) occurs for each one.
Later, I tried the full mapbox url (the map url with the "?access_token=..." at the end). In this case, immediately after press save in "Server Settings", the browser developer tools console shows "PUT http://localhost:8082/api/server?_dc=1466808899494 400 (Bad Request) ext-all.js:22". Using browser developer tools, an inspection in Network->Response tab reveals the following error (edited map url):

{"details":"Value too long for column &quot;MAPURL VARCHAR(128)&quot;: &quot;'https://api.mapbox.com/user/map/{z}/{x}/{y}?access_token=123456789... (191)&quot;; SQL statement:\nUPDATE server SET\n registration = ?,\n readonly = ?,\n map = ?,\n bingKey = ?,\n mapUrl = ?,\n distanceUnit = ?,\n speedUnit = ?,\n latitude = ?,\n longitude = ?,\n zoom = ?,\n twelveHourFormat = ?\n WHERE id = ?; [22001-191] - JdbcSQLException (... < QueryBuilder:431 < DataManager:463 < ServerResource:46 < ...)","message":"Value too long for column &quot;MAPURL VARCHAR(128)&quot;: &quot;'https://api.mapbox.com/user/map/{z}/{x}/{y}?access_token=123456789... (191)&quot;; SQL statement:\nUPDATE server SET\n registration = ?,\n readonly = ?,\n map = ?,\n bingKey = ?,\n mapUrl = ?,\n distanceUnit = ?,\n speedUnit = ?,\n latitude = ?,\n longitude = ?,\n zoom = ?,\n twelveHourFormat = ?\n WHERE id = ?; [22001-191]"}

So, it seems that the full mapbox url is too long.
Any ideas or workarounds for solving this issue?
Thank you in advance for any help you can provide.

Anton Tananaev8 years ago

Looks like you need to manually change column size in the database.

JanB8 years ago

Hi.
Finally, following your last suggestion, I was able to use a mapbox map as base layer.
Thank you.

Anton Tananaev8 years ago

I've already added an task to my backlog to increase column size, so it should be fixed for everybody in one of the next releases.

JanB8 years ago

Ok, thanks for your time.

acast6 years ago

Hello Friend.
How did you solve the issue?

Murthy Varanasi4 years ago

jan cna you help me with the url directions because I am goilng clueless on dding the map to traccar

Rock4 years ago

HI! Can you put the long "URL" ??? without the token!!!

Murthy Varanasi4 years ago

I put the long url including token and it worked

Rock4 years ago

SORRY! I was misunderstood! If you can share the URL, for others!

Murthy Varanasi4 years ago

sorry for the late reply got caught up with work. This is the url that worked for me

https://api.mapbox.com/styles/v1/[USERNAME]/[STYLE ID]/tiles/256/{z}/{x}/{y}@2x?access_token=[TOKEN]
Rock4 years ago

THX!!!! Worked for me too!!!

Murthy Varanasi4 years ago

It worked using this url? If so then I am happy helping someone.