get all possible directions from A to B - google-maps

I want to find all possible routes from point A to point B (not only shortest ones). So my question is, is there any web service api (because I use Java) for such request in Google Maps, Yahoo Maps etc. it doesn't matter which one..

I've found something about this topic in Google Maps Directions Api: "alternatives (optional), 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." But unfortunately, I couldn't use this option, when I include alternatives=true inside request query I get the same result. That would be nice to have such an alternative - it's more flexible, but I found something guarantied one with waypoints (but its much like "hardcoding" - we specify streets that we will pass from). Anyone tried alternatives=true?!

Here's another approach and solution for this problem: convert meters to latitude longitude from any point
Thanks for your responses..

I'm using the fact that google maps' paths uses rounding boxes to get a circle, to do so i just choose the point that i want and create a route to another that is not the same but very very close to it, just like:
http://maps.googleapis.com/maps/api/staticmap?size=400x400&path=color:0x5600FF80|weight:100|51.5285582,0|51.5285583,0&sensor=false&zoom=15
We can choose the weight as the diameter of the circle, note that it is a fixed value, not related to the screen size and the zoom.

Related

Locating current Google Place i'm at by latitude/longitude via Google Places API

i have a lat/long location data and i need to get current Google Place where i'm at now.
For example, if i'm in a shop(cafe, gym, etc..), i need to get info about THAT particular shop(cafe, gym, etc..).Or at least the closest one.
So, i'm doing it this way:
First i fetch place basic info(placeid,name, etc.) via Google Places API Nearby Search request:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.7597351,-73.9836576&radius=16.66&key=...
Then i find the closest one(which is apparently where i am) and perform Place Details request with it's placeid
So, everything works fine, except for some places like the one located at 40.7597351,-73.983657 (New York Guitar lab shop) which i can see on google map, but can't get in my response. Even places that are further from my location than this, are being found fine.
I've already tried to use rankBy=distance and then checking if the result is in required radius manually, still no use. Actually, maybe this approach is right, but as told in the docs, it's required to use types parameter with rankBy=distance. So, i set types=establishment since i actually need everything except addresses and locality tokens returned. I think that the problem is some places i need, are neither counted as establishments nor as localities, but i don't know the optimal way to exclude
all types specified at (https://developers.google.com/places/documentation/supported_types) Table 2 from my response. Is there a way to get only places which types are in Table 1 (except for specifying them ALL in my types param, haha)
So, could you please help me with how can i do this?
Thanks:)
P.S. here is very similar but unaswered question
Google Places API Displaying Inaccurate Result
It seems that there's explanation here (https://developers.google.com/places/faq#why_are_some_places_never_returned_even_though_they_have_google_pages). Looks like some places are just not yet verified by Google.
And yes, the establishment is the generic category for all non-localities. So you can be sure that if you set type=establishment then you'll have as much places as you will, if you'll specify all types from Table 2. Good Luck!

Google Maps API - Getting Street Coordinates

Google Maps API has any way to get the street coordinates of an location?
Is simple: I just want to get the nearest street coordinate. To got this i need, for example, all coordinates that compose a street.
Are there something like this?
You may use the directionService.
Pass the given address(or location) as origin and destination to directionsService.route() and use the travelMode DRIVING . The response should contain the nearest street.
Demo: http://jsfiddle.net/doktormolle/W3VGN/
I found this (ReverseGeocoding in v3): https://developers.google.com/maps/documentation/javascript/geocoding#ReverseGeocoding
Since this thread is old I suppose this could be useful.
These answers are all old, and Google has rearranged the maps API significantly since the answers.
In 2018, the best way to turn a location (long, lat) into a "point on road," is to use the snap-to-road or nearest-road service:
https://developers.google.com/maps/documentation/roads/snap
Note that this API charges a cent per API call, and can take up to 100 distinct points per call. If latency and complexity aren't problems, if you need to answer this question on a client, you could build a server that collects up to 100 requests from different clients, makes one request to Google, and then returns the request data back to the appropriate clients. (For this use, make sure to use nearest-road, not snap-to-road.)
Also, currently, Google Maps has a $200 per-month statement credit available, which may make smaller uses of this API not actually end up costing much (or anything at all.)

Get type of terrain by coordinate

I'm looking for a solution to be able determine landscape type by a given coordinate, for example check if current position is water/forest/town/road and so on. I found google.maps.MapTypeStyleElementType object specification in the Google Maps specification, but not sure if it could help me or not.
Probably, there are some another Maps API with such functioality? Or maybe I should refer to the different types of offline maps?
Nope, the link you send is just for styling the proper features, not to tell which feature is at a given coordinate. If you are interested in landscape, then Corine Land Cover is the thing you are looking for. It describes the types of biotops like forest, water, but also land use - meadow, field, buildings etc. However, I don't know if there is such an online service where you could query particular coordinates. Other solution for you would be to import these GIS layers (they are freely available) to your own gis map server. Maybe this is partially solved as there are e.g. projects how to incorporate these into openstreetmap.
Well not quite, but you could get close to what you're looking for by using the Google Reverse Geocoder and the Google Places API
Google Reverse Geocoding
http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
If you send the service a geocode it will send back an address type and/or one of several adress components http://code.google.com/apis/maps/documentation/geocoding/#Types
Google Places API
http://code.google.com/apis/maps/documentation/places/
You could use the Google places API to search for for what's near. If the geocode is in the middle of the lake, the Places API may return something like "Lake Michigan" and then you'd know the terrain obviously.

Modify the road calculation algorithm in Google Maps API

I would like to know if it is possible to change the way the itinerary calculation algorithm works in the Google Maps API (or Bing Maps). Basically, I'd like to add options, like for example "shortest route" or "avoid highways and national roads".
I haven't found anything in the API that might manage the road's cost, so I think it's not possible but maybe someone's got an idea of a way to do that?
There is no way to modify the pathfinder algorithm beyond the avoidHighways and avoidTolls options. See here for documentation:
http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsRequest
Another method would be to specify provideRouteAlternatives and figure out which of these routes is best according to your own heuristic.

Getting coordinates and names for a driving route

Is there any way to get the geo coordinates for a driving direction from Google Maps API?
if we use URL to show the driving direction with source and destination address we'll get the map and route as an webpage, instead of that I like to get the co-ordinates and details in some XML like format.
Sure, see the docs. You make a GDirections object (without a div AND without a map so nothing will be displayed by default and you'll handle all the displaying), and call its load method, specifying getPolyline and getSteps as both true (so you'll get the polyline and the textual directions despite the lack of div and map).
The GDirections' object load event fires when the results are ready. Then you use getPolyline, getNumRoutes, and getRoute methods on the object to retrieve results.
As a full reference, also check this (both GDirections and GDirectionsOptions)...!
The Google API documentation has a section on XML requests and parsing. It's quite detailed, many options available.
Hai all,
Finally i got the solution, google also provides the driving directions in JSON format, we can parse the JSON data and that will give all the details including coordinates, name, description, distance and approximate time
example:
http://maps.google.com/maps/nav?key=YOUR-MAP-KEY&output=json&q=from:sourceAddress to: destinationAddress
Thank you all for the support