How to get box using routeBoxer using Google Direction apis in php? - google-maps

I am trying to get overview_path in google direction api, but it not appearing in the response.
When i am using js sdk , I am getting the overview_path array in routes array but when I tried calling the direction api in postman, overview_path array is missing in the routes array.
Here is the url of postman.
https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood4&key=please_add_your_key&alternatives=true&units=metric&mode=driving
I am trying to get boxes for my path using routeBoxer.

There is overview_polyline which is encoded version of the overview_path, you need to decode it and you will get lat, lng of it.
http://unitstep.net/blog/2008/08/02/decoding-google-maps-encoded-polylines-using-php/

Related

OSRM route directions

Here is what I am trying to do. I have a pair of lat, lngs and I am trying to find the route between the pair of lat, lngs using OSRM. I extracted polylines from each step object using the OSRM route service output but couldn't figure out how to extract the direction for each step. How do I get the direction for each step?
See the API documentation for parameters to modify the response.
Passing steps=true will return RouteStep objects. A RouteStep contains the information you are looking for, i.e. StepManeuver objects, Lane objects and Intersection objects as well as distance and duration.
https://github.com/Project-OSRM/osrm-text-instructions should help. It's a nodejs application. I've wrapped it into an api; Now after fetching the directions from OSRM, I call the directions api and get the text directions.

Google Directions API limited versus Google Directions Javascript.API

If I make a request via javascript, I get a JSON object returned that has Routes, Legs, Steps ,and Path data, the latter being a set of Lat,Lng co-ordinates along the step.
https://maps.googleapis.com/maps/api/js?...query for the javascript and then using the directionsService function
If I make a request server-side, with exactly the same request, I only get Routes, Legs and Steps data returned, no Path data.
https://maps.googleapis.com/maps/api/json?...query
Has anyone else experienced this? are there any workarounds? Uisng the other URL in each application just returns a 404.
You can extract path data from the polyline property of the step:
polyline contains a single points object that holds an encoded polyline representation of the step. This polyline is an approximate (smoothed) path of the step.
https://developers.google.com/maps/documentation/directions/intro#DirectionsResponseElements
Encoded polyline algorithm is described here:
https://developers.google.com/maps/documentation/utilities/polylinealgorithm
Google Maps JavaScript API has a static method in geometry library to decode the encoded polyline:
https://developers.google.com/maps/documentation/javascript/reference#encoding
For Android apps you can use Google Maps Android API utility library that contains polyline decoding and encoding functions:
https://github.com/googlemaps/android-maps-utils
Google Maps iOS SDK also has static method to obtain a path from encoded polyline:
https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_path
Hope it helps!

Display Google Map API route on map

I am new to google Map Api V3, and i am planning to find the best route among some waypoint.
I found that the direction API could solve my problem (http://maps.googleapis.com/maps/api/directions/json?...)
I got the Json output, but is there any way to display the route on Google map directly?
Or i should parse the Json, get the legs information, and plot it again??
Thanks a lot

is jsonp possible in google map

I want to know is JSON padding 'jsonp' works in Google map API ?
In an application i have to implement google map by replacing bing map(already developed).
In below url bing uses jsonp to respond back the response
https://dev.virtualearth.net/REST/v1/Locations/37.556141,-122.287880?output=json&jsonp=LocationPane.drawLocationHistory_0_OnMap&key=SOME_KEY
I tried to prepare the url as and also tried many combination of it
https://maps.googleapis.com/maps/api/geocode/json?latlng=18.5236,73.8478&jsonp=LocationPane.drawLocationHistory_0_OnMap&sensor=false
but its not working as it works in Bing map.
Please let me know is json padding possible in google map or is there any better way to use geocoding
jsonp is currently not supported by the geocoding-webservice.
But you may use the geocoding-service of the JS-API to retrieve the results and pass them to the callback-function.

How to get dynamically latitude and longitude on google maps?

I have country and address. How can I retrieve latitude and longitude from Google Maps V3?
I will use this to load the map.
EDIT
This is my actual code, but seems that Google API return this error : W[B].bindTo=function(a,b,c,d){var c=c|...R[p](this,wf,a);this.Pb&&this.Pb(a)};
SOLUTION
remove center: location,
You can retreive this with Geocoding Requests.
You can see my last project that I used this here. See function AddMarker in gmaps3.js for a working real world example. Basically I fetch addresses from database (using AJAX) and then convert them to lat/lon to make markers on the map.
You can use their ReST-API.
http://maps.google.com/maps/api/geocode/json?address=Berlin+Germany&sensor=false
The documentation is in The Google Geocoding API. You will have to do a http request e.g. $.get in jQuery to perform the query and then parse the JSON. Other output formats include XML. There's a JavaScript geocoder on their site as well.
You need to access geocoding.
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
http://code.google.com/apis/maps/documentation/geocoding/index.html