I would like to develop an Android application that allows users (pedestrians) to follow an automatically generated route.
Users would specify how far they wish to walk, whether they must return to their stating position, avoid hills, dangerous roads, not cross any roads, how fast they walk on avergae, etc.
i have been searching for a java based library or service that generates a route but have failed.
can anyone recommend a java library that will automatically generate a route?
Interesting idea. I've never seen any library or available implementation that matches your requirements exactly. What you are attempting to do, though, is basic route optimization.
Look at some combination of the google directions API (https://developers.google.com/maps/documentation/directions/) and a set of pre-defined (that you set up) waypoints around the city. The waypoints represent nodes in your "graph" and the edges are routes between them. Waypoints have coordinates so you can map them. Then you assign weight (preference) to each edge and use google to calculate the distance between the waypoints. Extract the routes that match your distance preference and then pick the one with the best "weight" preference.
Related
I am working with the Android project. I want to draw the route between two points which is showed public transport routes like bus and train, not the shortest route. I am using google direction API and google map API.
I want to just make it like google map where they show the suggestion of bus and times like this when we choose locations.
is there any special API for public transport route?
you can use mode parameter in directions api like this
https://maps.googleapis.com/maps/api/directions/json?
origin=place_id:ChIJ685WIFYViEgRHlHvBbiD5nE
&destination=place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y
&mode=transit
&key=YOUR_API_KEY
Travel Modes When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:
driving (default) indicates standard driving directions using the
road network.
walking requests walking directions via pedestrian paths &
sidewalks (where available).
bicycling requests bicycling directions via bicycle paths &
preferred streets (where available).
transit requests directions via public transit routes (where
available). If you set the mode to transit, you can optionally
specify either a departure_time or an arrival_time. If neither time
is specified, the departure_time defaults to now (that is, the
departure time defaults to the current time). You can also optionally
include a transit_mode and/or a transit_routing_preference.
I'm using the Google Distance Matrix API with Java. I want to calculate the train-distance between two cities. One of the cities has no train station. The problem is, google doesn't just calculate the train-distance. It always adds the car-distance from the city without trainstation to the next city with a train station. But for my project i just need the train-distance.
This is a part of my code:
DistanceMatrix matrix = DistanceMatrixApi.newRequest(context)
.origins(origins)
.destinations(destinations)
.mode(TravelMode.TRANSIT)
.transitModes(TransitMode.TRAIN)
.units(Unit.METRIC)
.await();
In the documentation I can't find a solution for this problem.
The Google Maps search algorithms were designed to solve real-world transportation routes, which means that sending a train to a location where the passenger cannot get off is not feasible and therefore not reflected in the routes. I cannot think of any way to extract that information from Google Maps, except possibly doing a direct Directions query, though I doubt it would have different results, since it uses (as far as I can tell) the fundamentally same algorithm for all of its services.
Using a database such as OpenStreetMap (using free, limitless APIs like Overpass to access via HTTP in Java) is probably the best solution. If you want a quick fix, and you are capable of identifying cities without train stations, taking the linear distance between the two cities probably returns a reasonable (though deflated) estimate using the Geometry Library.
Sorry there is not a solution I can see, but this is the best I have.
I'm developing an Android app, but I'm not sure how to do the next thing: there is one biking route that we've chosen. The users should get directions for continuing along this biking road.
So Google Directions should stay on my route and not choose a road that is not within my route to get to the end of the biking road.
Any idea how this could be done?
If I understand you right, you wanna have a route from Google Directions, which should match your determined route.
Well, it could be hard to manage that because Directions is designed to find the shortest path between two points. One way is to use the option of waypoints, to limit the suggestions of the API. Simple said, don't use just a origin and a destination. Use as much waypoints as you have to between the origin and the destination to get the nearest route possible.
Getting the exact route as you think of it is just big luck.
I'm developing a indoor navigation program for android, and i'm stuck right at the beginning:
How do you represent a map in java?
I will prefer a way that will allow me to apply Dijkstra's algorithm easily.
note: i need the program to know the size of each room and where are the entrances and exits.
edit: i'm looking for a object to use in the BL not the UI
Android has a built-in GUI element called a mapView that you can add to a screen in your application. It is a Google map and will require you to obtain your applications API key. You can add overlays to it and locate points on the map based on latitude and longitude (I think it supports other methods as well) and these points could be used for Dijkstra's algorithm.
Hope this helps, good luck.
I think, what you are describing is a extended topological map (where you have an estimate on the nodes absolute location). So you basically need a component that can draw a graph with locations attached to the nodes. Also, you might want the possibility to draw addistional stuff (like heat maps for wifi connectivitiy, bluetooth devices or whatever you are using to estimate your position and gather information about the environment). You are also dealing with the SLAM problem.
I don't know of any existing component that can do the visual task for that, but maybe you find something with google. I wouldn't however recommend it. I would just create my own component (using a TextView and draw my stuff on that). It is much more flexible, not that much of an effort and you can choose the functionality and data format, which can be very helpful in such cases...
Once you have all the rest running (which is a lot!), you still can decide to look for some fancy component that may integrate even google maps, is able to zoom or so.
Hi
I'm working with google maps api in both javascript and java on respectively a pc and android. There's probably a difference, but I've been looking around in the documentation for a max number of markers that is a good idea to put on the map, to not have a system crash. It's probably a lot smaller on android, but I really have no idea of an estimate is it 25 - 100 - 1000?
So that's why I'm asking you. What is the maximum number of markers on a map that the user system can handle on pc and android? I know that it depends on the individual system, but I also bet that there are some guidelines I'm not aware of, that I can follow to optimize the user friendliness of my applications.
thanks
From the Google documentation
There is no limit to the number of
markers or path vertices supported by
the Google Static Maps API. However
Static Maps API URLs can be a maximum
of approximately 2,000 characters
which constrains the number of markers
and path vertices that can be
specified based on the number of
decimal places used when specifying
each latitude/longitude pair.
However, you should consider whether your application is overloading the users ability to select from so many markers. Ideally, your application should be doing the filtering for them and only showing a few simple, well spaced choices to allow for big thumbs on the touchscreen.
I would suggest that you use a zoom level manager after reading this article that describes one.