DirectionServices JSON to Google Map (or alternative map display) - android

Is there a simple way to achieve showing the output from DirectionServices onto a Google Map? The closest I could find was this answer -- How to draw road directions between two geocodes in android google map v2?
But that needs a bit of modification...
I'm ok with either Google API or 3rd party libraries too
Thanks,
Ram

Given in Google Maps JavaScript API - Displaying the DirectionsResult, you may opt to handle yourself the DirectionsResult which contains the result of the directions of the query or you can choose to automatically handle displaying the result on a map by passing a DirectionsRenderer object.
To display a DirectionsResult using a DirectionsRenderer, you simply need to do the following:
Create a DirectionsRenderer object.
Call setMap() on the renderer to bind it to the passed map.
Call setDirections() on the renderer, passing it the DirectionsResult. Because the renderer is an MVCObject, it will automatically detect any changes to its properties and update the map when its associated directions have changed.
A DirectionsRenderer not only handles display of the polyline and any associated markers, but also can handle the textual display of directions as a series of steps. To do so, simply call setPanel() on your DirectionsRenderer, passing it the <div> in which to display this information.
More information and examples to fully understand Google Maps JavaScript API - Directions Service can be obtained from the documentation.

Related

Google Maps: open URL by coordinates but show the location name

I've been trying to open Google Maps (specifically on Android, but not necessarily) from a coordinates URL, such as
https://www.google.com/maps/search/?api=1&query=51.5055,-0.0754
But when the map opens, I want it to show the location name such as "Tower Bridge". Not the coordinates 51.5055,-0.0754
I have tried something like
https://www.google.com/maps/search/?api=1&query=51.5055,-0.0754&query_place_id=Tower+Bridge
with no luck. When maps opens it shows the coordinates, not the place name.
I am okay with either "injecting" the location name (something like https://....&location_name=Traitors+Gate), and/or with maps revealing the location name (reverse geocoding) from the coordinates.
Motivation: Coordinates are more accurate and less ambiguous than location names. For example, there is Jerusalem, OH and there is Jerusalem, Israel, which is half a world away. Or, "Palais de Louvre" which is just one building but one huge building over four streets, with multiple entrances. Coordinates solve those issues, but they are not "Human readable". You can't present "49.3697,0.8711" to a user and expect them to recognise the Omaha Beach.
Thanks
Unfortunately, the Google Maps URLs doesn't support this kind of sending labels. You should send a valid place ID value in order to get correct title of the place in Google Maps app.
You will need one additional step to do this. Execute reverse geocoding request for coordinate and get a place ID.
https://maps.googleapis.com/maps/api/geocode/json?latlng=51.5055%2C-0.0754&language=en&key=YOUR_API_KEY
This will return a place ID ChIJlRsEuUgDdkgRSM7ciIhVooM of Tower Bridge. Have a look at this example in Geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D51.5055%252C-0.0754
There is a Java client library for Google Maps API Web Services that you can find on GitHub:
https://github.com/googlemaps/google-maps-services-java
You can use this library to execute geocoding requests, alternatively you can also use Places API nearby search to get the nearest place. Note that web services require a different API key, because they don't support Android app restriction that you use in API key for Maps Android API.
Once you get a place ID value just create Google Maps URLs link. E.g.
https://www.google.com/maps/search/?api=1&query=51.5055,-0.0754&query_place_id=ChIJlRsEuUgDdkgRSM7ciIhVooM
I hope this helps!

Directions API Live tracking in android app

I am trying to use google maps directions API with continuous hitting to the API and updating the directions by getting a current location on location changed listener and it works perfectly.
But Instead of hitting multiple times I need to get directions API for the single instance and write an algorithm by getting the directions using segments start point and update on google map, Find a way to know the user is traveling in the wrong distance and re-route map by calling API.I tried these ways and working but there are a lot of cases to be handled for these scenarios.
I don't understand what to follow and why this is required is, we have a display cycle and the user starts the navigation and directions should be shown on cycle hardware display via BLE.
Please help me solving this issue.
You can try using the Google Maps Util Library. The PolyUtils class has methods to check if a LatLng lies on a polygon/polyline.
Maybe try using the method isLocationOnPath. And if it's outside the polyline, make the request to directions API and re-plot the route.
Docs: http://googlemaps.github.io/android-maps-utils/javadoc/

Google Map's API for BMTC (Bangalore Metropolitan Transport Corporation)

I am working an Android App that displays bus route information when users inputs a route number.Is there any way i can fetch this information using google map's API??
As #VolAnd said, this question is very wide.
I found something that might help you if i understood you question correctly.
When user inputs a bus route number, you want to fetch route details( bus stops and timings).
Well for this you can use http://www.mybmtc.com/ search api.
You can check this link to know how to use it, but its in Python language.
... i can fetch this information using google map's API?? ....
If you want to search bus routes and show it on google map, then you can use google maps api's Direction service documentation. You need to specify travelMode as TRANSIT and TransitMode as BUS. You can specify all in between stops as waypoint[] in TransitOptions
So a quick answer,
Get and validate route number provided by user using mybmtc.com search.
That will give you details of all the stops on that route.
Use google maps Direction service to locate routes between origin and destination of that route.
You have to work hard for this.
Let me know if anything is missing.

how to check a point is accessible through road (Android)

i'm getting latitude and longitude of a location, I want to know the roads connecting to that location and whether it is land or water
I tried one google map api which is not helping to get the information i want.
http://maps.google.com/maps/api/geocode/json?latlng=40.7127,74.0059&sensor=true
Another SO answer pointed out two possible workarounds:
You can use Google Maps Reverse Geocoding . In result set you can determine whether it is water by checking types. In waters case the type is natural_feature. See more at this link http://code.google.com/apis/maps/documentation/geocoding/#Types.
You can detect waters/lands by pixels, by using Google Static Maps. But for this purpose you need to create http service.
You can use the Google Maps Geocoding API which does exactly that: http://code.google.com/intl/da-DK/apis/maps/documentation/geocoding Take a look at the "Reverse Geocoding" section

Is it possible to have the built-in Google maps display an address

When passing coordinates to an Intent to show the location centered in the Google Maps app, is it possible to have it display the address, too, or any kind of label, or are the coordinates the only thing that can be passed/the only way the map can be manipulated?
I know I can use a MapControl and take full control of it, but I'm wondering if I can simply invoke the maps app and show a geocoding of the coordinates passed in as a label.
I dont think that you would be able to make any changes in the default maps application. You might want to use map widget by regestering for a mpas api key and build a custom app.

Categories

Resources