Skip to content
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 about routing? #461

Closed
augusto3691 opened this issue Nov 12, 2019 · 21 comments
Closed

How about routing? #461

augusto3691 opened this issue Nov 12, 2019 · 21 comments

Comments

@augusto3691
Copy link

The leaflet has a pretty good routing machine with a way to calculate custom routes based on a GeoJson named pathfinder, there some roadmap for that ?

@ptv1p3r
Copy link

ptv1p3r commented Jan 8, 2020

also would like to know that, how can i implement routing with this package?

@augusto3691
Copy link
Author

After some research, you ll need to create a A* by yourself, if you use public routes i suggest move to google map implementation of flutter

@ibrierley
Copy link
Collaborator

I think it depends on what your goal is. You can certainly interface with a routing API like mapbox, and get directions and then draw them in flutter_map, that type of thing. But it's not clear really from the original issue what is needed, and that doesn't really need to be included as part of maps (i.e it's a separate entity really).

@ptv1p3r
Copy link

ptv1p3r commented Jan 29, 2020

I would need to do the same as in google maps like so :

`List result = await polylinePoints.getRouteBetweenCoordinates(
appSettings.getString("MAP_GOOGLE_KEY"),
latitudeSource,
longitudeSource,
latitudeDestination,
longitudeDestination
);
if(result.isNotEmpty){
// loop through all PointLatLng points and convert them
// to a list of LatLng, required by the Polyline
result.forEach((PointLatLng point){
polylineCoordinates.add(
LatLng(point.latitude, point.longitude));
});

  Polyline polyline = Polyline(
      polylineId: PolylineId('poly'),
      color: Color.fromARGB(255, 40, 122, 198),
      points: polylineCoordinates
  );

  globals.googlePolyLines.add(polyline);`

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 28, 2021
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as completed Apr 2, 2021
@JaffaKetchup
Copy link
Member

I know this issue is closed, however I'd like to bring attention to http://project-osrm.org/. It's a free routing machine based on Open Street Maps. I'm currently in the process of making a plugin for this (or a separate package with extra support for flutter_map), but I'm quite busy at the moment, so there's no ETA.

@volethanh
Copy link

I know this issue is closed, however I'd like to bring attention to http://project-osrm.org/. It's a free routing machine based on Open Street Maps. I'm currently in the process of making a plugin for this (or a separate package with extra support for flutter_map), but I'm quite busy at the moment, so there's no ETA.

I hope the plugin will be available soon

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Aug 12, 2021

@volethanh For now you can use the GitHub Experimental Alpha. Please don't use it in anything production-wise yet though.

https://github.com/JaffaKetchup/flutter_osrm

Here's a small example line just for now:

import 'package:flutter_osrm/flutter_osrm.dart';

// Get a 'nearby' point
OSRM(OSRMProfile.car).nearby(LatLng());

// Get a route between two points
OSRM(OSRMProfile.car).route([LatLng(), LatLng()]);

apart from that, you'll have to figure it out yourself for now, as I'm not really dedicating my time to it at the moment (I'm maintaining another plugin for flutter_map, I am writing new docs for flutter_map, and I've got my own personal project).

@volethanh
Copy link

@volethanh For now you can use the GitHub Experimental Alpha. Please don't use it in anything production-wise yet though.

https://github.com/JaffaKetchup/flutter_osrm

Here's a small example line just for now:

import 'package:flutter_osrm/flutter_osrm.dart';

// Get a 'nearby' point
OSRM(OSRMProfile.car).nearby(LatLng());

// Get a route between two points
OSRM(OSRMProfile.car).route([LatLng(), LatLng()]);

apart from that, you'll have to figure it out yourself for now, as I'm not really dedicating my time to it at the moment (I'm maintaining another plugin for flutter_map, I am writing new docs for flutter_map, and I've got my own personal project).

May I ask something just about this osrm as you mentioned above ?

I use this var osrmRoute = await OSRM(OSRMProfile.car).route(polylineCoordinates); to get osRMRoute and then I use nodesLocations to simple create Polyline

Screen Shot 2021-08-13 at 11 28 02 PM

Screen Shot 2021-08-13 at 11 28 10 PM

Then add it to Widget

Screen Shot 2021-08-13 at 11 28 32 PM

but the map cannot show the route instead of it show a line between 2 point.

Screen Shot 2021-08-13 at 11 32 26 PM

Thanks for your help.

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Aug 13, 2021 via email

@volethanh
Copy link

volethanh commented Aug 14, 2021

Hi there, this should be drawing a route (it did in my testing), I think you're using it incorrectly, but I'll need to double check. Give me a bit of time and I'll be back. PS. Just to check whilst I'm checking, can you put your waypoints through .nearby() before using .route()?

Ah sorry, I found what make it wrong.

Firstly, the api I've used is OSRMRouteTrip var osrmRouteTrip = await osrmTrip(OSRMProfile.car, polylineCoordinates) and it caused me an error when parsing returned value from api .decodePolyline(apiResponse[0]["waypoints"]["location"])

Secondly, I think the api https://routing.openstreetmap.de is the problem and it is only use for routing in Germany, I've changed it to my built api using OSRM project backend and I've changed to my api and it worked but it didn't draw a route.

Currently, I don't know why the routing is a bit difference.

this is my api link
http://routing.myownserver.com:5000/route/v1/driving/-122.084,37.4219983;10.0,10.0;105.848,21.6016;106.7368025,10.8273073?overview=false&alternatives=true&steps=true&hints=;;;

And this this the link from routing.openstreetmap.de
https://routing.openstreetmap.de/routed-car/trip/v1/car/-122.084,37.4219983;10.0,10.0;105.848,21.6016;106.7368025,10.8273073?overview=false

After reversed all the code and use what you guide. Now it work

OSRM(OSRMProfile.car).route([LatLng(), LatLng()]);

thanks for your time to help me

@JaffaKetchup
Copy link
Member

I set it to use the German routing because it supports car, walk and bike, and it routed correctly when I tested it in my local area in the United Kingdom, so not sure why that's a difference? But glad it works now!

If you don't mind, apart from the ability to change the routing server URL, what other options would you like to see, if any?

@thorizer
Copy link

thorizer commented Dec 8, 2021

@JaffaKetchup is it possible to add waypoints or only A to B ?

@JaffaKetchup
Copy link
Member

Hi @thorizer,
You can route between as many waypoints as needed. Note that the more waypoints used the more expensive the processing becomes (time and power).
I am still very slowly working on this plugin in the background, and it has changed (only on my local device) significantly from the version on GitHub: please do not use this for serious projects at the moment.

@thorizer
Copy link

thorizer commented Dec 8, 2021

@JaffaKetchup, thanks can't wait!
I switched from react native to flutter because of the availability of leafleat and osrm.

@JaffaKetchup
Copy link
Member

Good to hear! Hope it all meets your expectations!

@nkdkhanh46
Copy link

You can use this package for the routing:

https://pub.dev/packages/flutter_map_directions

@aytunch
Copy link
Contributor

aytunch commented Apr 3, 2023

You can use this package for the routing:

https://pub.dev/packages/flutter_map_directions

@nkdkhanh46 Hi, can we see the github repo? In pub.dev it does not link to gh. Thanks

@JaffaKetchup
Copy link
Member

(Also see #461 (comment). I still plan to work on it at some point!)

@nkdkhanh46
Copy link

You can use this package for the routing:
https://pub.dev/packages/flutter_map_directions

@nkdkhanh46 Hi, can we see the github repo? In pub.dev it does not link to gh. Thanks

The github repo has been added to pub.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants