-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to Draw a line along with position changes using mapbox android #5321
Comments
I"m not sure I understand your use case but i'll try to clarify how the Navigation SDK works. When a user moves off of the road and that is detected, a new route is fetched. Depending on connectivity and other factors there will be some delay from the time the user moves off of the route until a new route is fetched. When a reroute occurs the route line isn't automatically redrawn. One way to redraw the route line on the map when a reroute event occurs is with a If I misunderstood your issue. Please clarify. |
Thanks for your quick response, I want the example below. But in that
origin and destination points are fixed. In my requirement origin is fixed
and if the user moves, destination points will change dynamically, for
example if I started from x point, and will move to any destination
location. I want to draw a line with a moving icon along the user.
Below code will work for fixed origin and destination points. Kindly let
me know if there is any code available for my requirement
https://github.com/mapbox/mapbox-maps-android/blob/main/app/src/main/java/com/mapbox/maps/testapp/examples/linesandpolygons/MovingIconWithTrailingLineActivity.kt
Thank you.
…On Wed, Jan 5, 2022 at 12:56 AM Seth Bourget ***@***.***> wrote:
I"m not sure I understand your use case but i'll try to clarify how the
Navigation SDK works. When a user moves off of the road and that is
detected, a new route is fetched. Depending on connectivity and other
factors there will be some delay from the time the user moves off of the
route until a new route is fetched. When a reroute occurs the route line
isn't automatically redrawn.
One way to redraw the route line on the map when a reroute event occurs is
with a RoutesObserver. When the navigation core performs a reroute the
new route will be expressed by this observer. In your implementation you
should pass this route to the MapboxRouteLineApi class by calling
MapboxRouteLineApi::setRoutes and rendering the result by calling
MapboxRouteLineView::renderRouteDrawData. Here is a link to an example
<https://github.com/mapbox/mapbox-navigation-android/blob/944694940c09505de493600bd85926ca9f1813ff/examples/src/main/java/com/mapbox/navigation/examples/core/MapboxRouteLineAndArrowActivity.kt#L221>
.
If I misunderstood your issue. Please clarify.
—
Reply to this email directly, view it on GitHub
<#5321 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIK3KLAPZKFR4IVMR6WMZIDUUNCVXANCNFSM5LHI2I5Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Ok, let me point out some things that might be useful to you. It might not be obvious but a line is a collection of
To get an icon that moves with the user see the documentation here. You can listen for changes in the user's location and draw updated route lines by creating new line geometry based on the original collection of A library that would probably be useful to you is the Mapbox Java library. Also look at the Turf API, specifically TurfMeasurement and TurfMisc. There are methods for measuring distances between points which can tell you how far the user the user had moved off of the original route and the bearing etc. There are also methods for slicing a collection of points for creating route lines. |
Closing this for lack of activity. |
Android API:
Mapbox Navigation SDK version:
Steps to trigger behavior
Expected behavior
If user moves Lat\Lon coordinates will change, need to draw line even if lat\lon chnages dynamically.
Actual behavior
Currently by using origin and destination im able to draw line.
The text was updated successfully, but these errors were encountered: