How to show alternative directions in Google Maps? - android

I have collected data of specific restricted zones in Google Maps. Now I want that when a user opens my app for getting directions for a Point B from Point A, he should be shown an alternative direction which does not include the restricted zones which I have mentioned.
How should I proceed?
What steps should I follow such that those restricted zones get ignored while showing alternative directions from Point A to Point B?

To get alternative direction, you can use the Google Maps Direction API which is a service that calculates directions between locations using an HTTP request.
You can use the optional parameters alternative to provide one or more alternative route.
alternatives — If set to true, specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server.

Related

How to determine that the user is not on predefine route in android

I am developing an application based on location and map. I have a predefine route on map from location A to location B. Now i want to determine if any user navigates far from predefine route. How can we determine that the user is far away from predefine route. I tried a lot to find out any such API which is helpful but couldn't. Hope i will find some solution here.
You can use the PolyUtil.isLocationOnPath method from the Google Maps API Utility Library.

how to get route optimization from multiple destinations Google maps Android

I am Developing Android application in which i need to show available destinations to the user in Google Maps and provide route optimization with near and far destinations.
And Also set priorities to each and every destination LIKE eg:(1,5,3,2,4,6,7) etc.
Please can anyone help me on this topic.
I think this tutorial can help you with your problem. It uses a Google Maps JavaScript Direction Service. What you need is to create a structure request object and pass it into to a Direction Service Object and wait for Google's servers to respond via your callback function. After checking that the directions are "OK", you can iterate through the results object or pass it to a DirectionsRenderer Object provided by the Google API.
This tutorial gives you a sample code that will serve as a guide for you. For more information, you can also check this related SO question:
Using Google Maps 3 API to get multiple routes on a Map
Google maps API - adding multiple destinations

Navigating& providing directions to a user's GPS location

I've read Google's API policy on Location Services & Maps API, they do not allow one to make an app that provides directions to a user's location. I however wish to make such an app. I know I need to use a third party Maps API, but im unsure if this sort of app would be allowed on the play store.
I've searched extensively. The only references to this not being allowed in the the Maps API terms of service, but no where else. +
The idea is simple, one person sends a request to another, and they track each other with directions provided to find them.
Revalent reddit post by myself.
http://www.reddit.com/r/androiddev/comments/2qcm22/would_i_get_in_trouble_w_googles_policys_if_i/
I do not understand that it is difficult , you can use Google maps , first try to get another exact coordinates of latitude and longitude , and put them on a Google map , then make getting location via satellite.

Google distance matrix web service limit

According to this Google document there are limits on using Distance matrix web service.
From the document :
Use of the Distance Matrix API must relate to the display of information on a
Google Map.Use of the service in an application that doesn't display a Google map
is prohibited.
I am not clear whether I meet this limit or not.
Let me explain how I use this web service. I call this api from server to get distance between locations. Using this distance I just decide that user1's entered location is near to user2's entered location or not. I don't use this information to display on google map. But at client side I display google maps with marker for user's entered location and markers for nearby users' location.
Using web service and google maps this way, do I satisfy the above mentioned limit?
Note : I also call direction web service at client-side to display routes on map.
MAPS API
Your usage is fine. I think the whole point of the Google guidelines you quoted above are to stop people using the distance matrix and other Google Maps APIs (without a Google MAPS API business account) from using it outside of any "app" scope for financial gain or in situations where there is a simpler solution that doesn't require their API. (I will get to this soon)
This is also the reason they impose lower limits on the numbers of API calls you can make per day when using a free Google Maps key:
Normal - 2 500 elements per 24 hour period.
Business - 100 000 elements per 24 hour period.
I've used many of the Google maps API services on free accounts across a broad range of applications, some that match the scenario you have state above, others that do not. We have never had a problem at all and as long as people use the API fairly, they shouldn't either.
Other ways
There are other ways of doing what you require. You could calculate the distance between the two locations using the Haversine Foruma
http://en.wikipedia.org/wiki/Haversine_formula
and then send this distance down to your app upon request. This would remove the need for the Distance Matrix API in some circumstances (I'm unsure how indepth your App and Web Services actually are).
Why not instead use straight line distance between two points?
Try to find something similar to Android's Location.distanceBetween in the language you use for your server or just port the code from Android.

How to enable traffic information along a specific route in Google Maps V2?

Google Navigation shows the traffic layer only for a given route. With GoogleMap.setTrafficEnabled(true) I'll get the traffic information for the whole map.
I know how to draw polylines for a route from Google Directions, but how can I turn on the traffic layer only for that route?
Not possible as of API v2 version 3.1.36. You may want to post a feature request on gmaps-api-issues.
The difference between these two values (duration and a duration in traffic) indicates how delayed your customer is going to be on their way to or from their location.
Reference: Access Google's Traffic Data through a Web Service
Discussion: http://searchengineland.com/pull-google-maps-traffic-data-into-adwords-with-this-script-library-248934

Categories

Resources