Google Maps Android API v2 - DirectionsRenderer - android

I already searched on StackOverflow and Google. But i didn't find a real answer. I think there is just no DirectionsRenderer in the Android API. But can you acknowledge this?
If there is not DirectionsRenderer, how could i use the Android API to show a GoogleMaps and draw a Route on the Map?
I want to draw a nice route. Not just lines between the coordinates of each route-section which are also delivered from the Directions-Request.

I think there is just no DirectionsRenderer in the Android API. But can you acknowledge this?
There is no DirectionsRenderer in Maps V2. You can tell this by reading the documentation.
how could i use the Android API to show a GoogleMaps and draw a Route on the Map?
There is nothing in Maps V2 to support this.
I want to draw a nice route. Not just lines between the coordinates of each route-section which are also delivered from the Directions-Request.
You will need to find some Web service that will serve up coordinate information for the route with sufficient granularity (e.g., every 10m) to give you your "nice route", then use a Polyline or something like that for actually rendering the route.

SO i found out that it is possible to just take the legs, then the steps and within the steps you will find the "points".. when you decode the points string its a very detailed list of all coordinates.
with this coordinates, you can easily draw a nice route on the map.
so it's possible without the need of a additional Web-API.

Related

Extracting a graph from a map API in JAVA

My goal is to take several locations from the map and make a graph of them according to the paths between the locations. the locations will be the vertices and the paths between two locations will be the edges.
Draft of the idea:
I'm not so familiar with google maps API or another maps API's, but I will be happy if you guys could help me find a way to achieve this goal
You can use e.g. Google's direction API or Graphhopper to get the route, and then render them yourself through Canvas to a Bitmap.

What libraries to use for Android Project with maps and routing?

Alongside with my friends I am about to develop an android application. The application will use maps a lot, finding routes, placing markers, drawing predefined routes, stuff like that.
There is this Google Maps APIv2. So I tried it, write some code and looks good. I am able to place markers and draw polylines, however my application will have some predefined routes. One route is set of LatLng points. So I just add these points to PolylineOptions and add it to map. Great, it works.
But these predefined routes will be created in web-based application also using Google Maps APIv2 or similar api/library. Some streets are not straight they are curved so you need to create a lot of LatLng points to get it look nice which is very important. I can do this but I want to put only two LatLng points - at the beginning of the street and at the end.
Here is the image:
On the left, route has only two LatLng points (red dots) and that is desired shape of line. On the right same route with 2 LatLng points gives me route coloured in light blue, and this is what actually happens if I just add polyline to GoogleMap object. In order to create same effect as in left image, I need to create many LatLng (red dots) points which is not appropriate for those who will create these routes. So this leads us to routing problem which can be solved by using Google Directions API. Which solves the problem of drawing routes with less markers. Basically what I understood, this API for directions actually creates a lot of these LatLng points that I draw using for-each loop as seen on right part of picture above. And I need to contact Google Web Service for this so I need to have Internet connection - and this is the problem.
Sometimes internet will not be available hence I need some alternative solution. I've heard of Open Street Maps, but I am not sure how to use it and does it needs internet connection for creating these routes.
Is there any free library that offers offline routing and showing maps offline? Basically all map interactions must be done without use of internet.
But it is understandable if internet connection is needed only for the first run of application as it is needed for Google Maps APIv2, well application crashes until I turn on internet, after which any next run I do not need internet..
A web based application will be made for creating these routes and routes will be created by users for whom we develop this application. And as users can be very annoying they will demand some user-friendly and easy interface for creating routes. Telling them that they need to create 100 to 500 points for each route, and if there is 60-70 routes they will gladly say NO to our application.
Any advice? If it is possible, I can write my own routing algorithm for Google Maps to work offline, I am very skilful at "Algorithms and Data Structures" - any guides/tutorials for this? But I guess this map is just set of tiles, and does not have necessary information for finding route.... So please correct If I am mistaken for anything.
You can use the Scout SDK (provides a free usage quota) as it offers full offline maps, routing & navigation.
Have a look into the open source projects GraphHopper, Mapsforge and OpenScience-VTM which can do routing and/or maps offline. And all use OpenStreetMap data. Other projects exists of course, have a look here and here.
Also have a look into the GraphHopper map matching component which could be interesting for your specific use case and can work offline too.
(Note I'm the author of GraphHopper)
If it is possible, I can write my own routing algorithm for Google Maps to work offline
No you can't, the data is not open nor you can buy the data to my knowledge.
Another option is OsmAnd. The OSM wiki also has some information about OsmAnd and even more information about OSM on Android in general as well as pages about rendering and routing.

Google Maps Drawing Tools for Android

I need to make an Android app where the users have an option to draw a polyline on Google Maps and when the touch is removed, then do some action with the plotted polyline. Drawing and performing action is secondary. But the question is how could I achieve this?
Is there any predefined drawing tool (something like http://googlegeodevelopers.blogspot.in/2011/11/make-your-map-interactive-with-shape.html for JavaScript) to be used in google maps, or do I need to go with customization? Please suggest, or provide any links.
And can we extract the points to compare them with the ideal answer which was to be traced?
But the question is how could I achieve this?
With code. ;)
do I need to go with customization?
Yes. You would have to code all the functionality yourself. AFAIK there is no library that does that and of course Google Maps Android API v2 doesn't (and most probably won't) provide such functionality because it is too specific. I still think this would make a pretty useful library.
And can we extract the points to compare them with the ideal answer which was to be traced?
Yes. That would be simple after you are done with everything else.
Polyline polyline = ...
List<LatLng> extractedPoints = polyline.getPoints();
Simply use google maps api Google map API v2 following link might help you with the code.
code reference

Google Map v2 Get Direction Android

Can i get direction between 2 points with using Google Maps v2 in my Android application ?
I found Polyline but i don't want to draw a line between 2 points.
I found a solution which is using Intent. It can solve this problem but it is not useful because this solution is starting another map application and I want to show direction in my application. Can i do this ?
You cannot get directions using just the Google Maps V2 api. You should use the Google Directions API direction request call. This will return the raw direction data in json which would allow you to draw a Polyline for the directions on the map or show the data in any format you would like.
There isn't any method to do it because it envolves several computing that must be done in Google Maps servers (and they don't allow you to do so many without paying if you hold a business).
So, the only way is making a petition to google maps servers as they describe in the Google Maps Api documentation that #Bobbake4 linked. Then, you'll receive several coordinates that you'll use to draw a polyline which represents your route.
Hopefully, someone has already coded everything and shared gently with us here https://stackoverflow.com/a/15643705/1516973
That's absolutely the best answer covering Android Google Maps routing that I've found in Stack Overflow, so thanks to #Akexorcist and #emil-adz for it.

Google Maps Android API v2 routes json parsing

Hi With the help of LocationManager I managed to find current location in android.
For showing routes between two geo- co-ordinates what should I use so that I wont plot air distance instead will show ground routes or is it with help of json can I plot routes.
I have tried polyLine() but it gives straight line.
To work out the line between two points you need to know what map projection type you are using. Some map projections preserve shape (and therefore angles) others do not. Take a look at http://www.progonos.com/furuti/MapProj/Dither/CartProp/ShapePres/shapePres.html it might help.
If you're using a Mercator projection then I found this page that claims an algorithm in C# that should point you on your way: http://conceptdev.blogspot.co.uk/2009/01/great-circles.html
As for the line segments, ployline will give stright lines between the points. You'll need to use Path and use the Bézier curve methods Path.cubicTo() and Path.rCubicTo() from memory.
Do you have all permission set in the Manifest? Also, you have to enable the location service (is the gps icon in the status bar showing?). It'll take some time for the device to get the location, so see if onLocationChanged is called.
Here you can find the answer for your qustion:
Is there a way to show road directions in Google Map API v2?
and here:
Get driving directions using Google Maps API v2
basically what you should do is make a call to Google Directions API receive the road direction coordinates (many Latlng points), and then draw a polyline between each one of them.

Categories

Resources