Mapbox with Unity, draw a route from a GPX/KML
Hello,
i'm doing an experiment with Unity and I'm trying to draw a Route from a GPX/KML on a mapbox terrain-rgb map, so far the map is displaying fine: http://take.ms/ZP68Y
but I have no idea where to start to draw a route, there is not so much documentation about it or ressources anyone could help ?
thanks in advance
Jeremy
Answer by markusekblad · Sep 14, 2017 at 05:12 PM
Did you find an answer to this somewhere? Trying to implement this right now myself but I can't find any guides or documentation.
Answer by jbrialon · Sep 15, 2017 at 08:01 AM
nop, I gave up :(
let me know if you find how to do it
Answer by RavenLiquid · Feb 02, 2018 at 11:58 AM
I'm currently looking in to drawing lines on the map, but the documentation is indeed quite worthless in how to stuff.
I'm using a QuadMap by the way as I want it to zoom and scroll.
What I'm currently doing is using a line renderer, this takes a list of Vector3 positions to draw the line. To get the positions you need to get your coordinates which are stored in your GPS log, so either look for a lib that parses that or do it your self to get your list of coordinates.
Once you have your list, you can use the GeoToWorldPosition to convert your lat/lon to a Unity World position. You can use the one on the map component (this takes a Vector2d with your lat/lon) or on the Conversions (this also needs the map center and map scale).
Loop through this so you have a list of Vector3s and the do SetPositions on the line renderer. Also don't forget to set positionCount on the renderer as this doesn't take it from the SetPositions input length automatically.
Now fo the issues I have with this method. When moving the map around the line seems to lag behind the map (it needs to update each frame as the map position changes in World space when moving). It seems to work better when zooming. Another issue is that the height information is incorrect quite often. Even when using the tiles to query the height data for a coordinate.
It would be much better if there was an option to affix these things to the map itself so the position is at least auto synced with the map. Zooming might be more difficult.
I hope this helps you and @jbrialon
If you find some better ways to do some of this stuff let me know.
Your answer
Follow this Question
Related Questions
Which unity asset would you recommend me for map, route and geolocation 0 Answers
Help with dynamic loading or occlusion culling in scenes on 2D metroidvania? 1 Answer
map box tutorials for beginers. 0 Answers
Hello. How to make random items on map? 2 Answers
how can can input map in Unity3D like "Pokemon go" 0 Answers