I have an issue whith google maps directions service (api v3). I don't know how specify the origin and destination strings. For example for the requests:
http://maps.googleapis.com/maps/api/js?sensor=false®ion=ES&languaje=es&key=xxxxxxxxxxxxx&origin="EJIDO+EL,ESPAÑA,04700"&destination="CORCOLLE,ITALIA,00010"
or
http://maps.googleapis.com/maps/api/directions/xml?sensor=false®ion=ES&languaje=es&origin="EJIDO+EL,ESPAÑA,04700"&destination="CORCOLLE,ITALIA,00010"
the response of the server is: NOT_FOUND, ie route not found,
however if I change the character Ñ by N, ie ESPAÑA by ESPANA the response is OK.
There are other places with "especial characters" for example: Göttingen, München, Köln, ....
I have been looking for information in the documentation but can not find anything about.
How can I specify the different origins and destinations?
Regards,
Francisco
Request http://maps.googleapis.com/maps/api/directions/xml?sensor=false®ion=ES&languaje=es&origin="EJIDO+EL,ESPAÑA,04700"&destination="CORCOLLE,ITALIA,00010" is true, you can test it in browser.
If you have issue in request maybe it come from URL Encoding. With special character in string URL you need encode it before do request with this string
Related
I'm using MapQuest's GeoCoding API for a weather app I'm creating (this is due to having many complications using google's API), and the response returns each aspect of the address as a separate value, however unlike Google's API, there does not seem to be a value that returns the full formatted address (i.e 10 Duke Street, Putney, London, SW15 6EH, United Kingdom).
Am I missing something, or do I have to recreate this manually?
Use the outformat function
Reverse Geocode
outFormat
optional, defaults to json
Specifies the format of the response. Must be one of the following, if supplied:
json
xml
csv (character delimited)
Example: XML response
outFormat=xml
If you return the data as a csv from the API it is closer to the format you require as an address.
"Country","State","County","City","PostalCode","Street","Lat","Lng","DragPoint","LinkId","Type","GeocodeQualityCode","GeocodeQuality","SideOfStreet","DisplayLat","DisplayLng"
"US","FL","Duval","Jacksonville","32225","12714 Ashley Melisse Blvd","30.333472","-81.470448","false","0","s","L1AAA","ADDRESS","R","30.333472","-81.470448"
I am using the google-drive-sdk with our company-made device. We upload pictures made by our device to google drive. After that I try to list the files with a GET request to https://www.googleapis.com/drive/v2/files to get thumbnailLink and webContentLink. Everything is working fine except that when I switch to v3 I don't get the response I should. The documentation says I should get a metadata response like https://developers.google.com/drive/v3/reference/files
but I only get: id, kind, name and mimeType. What am I doing wrong?
As stated in Migrate to Google Drive API v3 documentation, there are changes on how fields were returned.
Full resources are no longer returned by default. You need to use the fields query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are returned.
You can see examples on Github. This SO question might also help.
In v3 they made all the queries parametric. So you can query passing some parameter like
var request = gapi.client.drive.files.list({
'pageSize': 10,
'fields': 'files,kind,nextPageToken'
});
This block of code will return you all the information of every file just like v2.
If you are sending a get request then for fetching all the information you can try GET https://www.googleapis.com/drive/v3/files?fields=files%2Ckind%2CnextPageToken&key={YOUR_API_KEY}
Suppose you need ownsers and permissions only then set
var request = gapi.client.drive.files.list({
'pageSize': 10,
'fields':'files(owners,permissions),kind,nextPageToken'
});
For GET request use GET https://www.googleapis.com/drive/v3/files?fields=files(owners%2Cpermissions)%2Ckind%2CnextPageToken&key={YOUR_API_KEY}
for reference you can use Google Developers Documentation for fetching File list
How do you specify an address in a Google Maps Web Services Directions API URL? The Maps Web Services page states
Converting a URL that you receive from user input is sometimes tricky. For example, a user may enter an address as "5th&Main St." Generally, you should construct your URL from its parts, treating any user input as literal characters.
However this isn't very clear. There are no examples and I haven't been able to find any on the web. Does this mean that, for the given example, "5th&Main St." the following valid?
https://maps.googleapis.com/maps/api/directions/json?destination=5th%26Main+St.&sensor=true
If not, what would be the correct conversion?
Thanks for reading.
As per my understanding, you are looking for URI encode.
In Javascript:
encodeURI is used to encode a string with special characters including
foreign language.
Example:
var address = "5th&Main St.";
var encodedAddress = encodeURI(address);
then pass the encodedAddress in the google maps API.
https://maps.googleapis.com/maps/api/directions/json?destination=encodedAddress&sensor=true
A small list of symbol equivalent encoding (Percent encoding):
space %20
! %21
" %22
# %23
$ %24
% %25
& %26 // this what happended in your case
' %27
( %28
) %29
Once I faced an issue, whild doing geocoding via C#.
Where I did a similar URI encoding using HttpUtility.UrlEncode() for address and then passed it to the Google API as I mentioned in above. Each language has its own encoding technique, yet the output is same.
Hope you understand.
I developed an app that sends GPS points to a server and the server convert those GPS points into a path, which is shown in a map.
Now the server makes a call to Google Maps Directions service and gets a response. From that response I use the value overview_polyline, which based on the documentation:
Contains an object holding an array of encoded points that represent
an approximate path of the resulting directions.
The problem is that sometimes the line I get is really weird. Sometimes it gives me a path where there's no street at all.
Here are some screenshots to describe my problem. The yellow marker is the start point (A), and the blue marker is the end point (B).
So I asked Google to give a route from A to B, with driver mode, so it shows the actually path.
And this is the result:
This is the API call I use. My question is: Any idea why would it return that path?
http://www.geocodezip.com/v3_example_geo2.asp?addr1=53%20Imperial%20Avenue,%20Westport,%20CT%2006880,%20USA&addr2=2%20Harborview%20Road,%20Westport,%20CT%2006880,%20USA&geocode=1&geocode=2&type=m
Looks to me like the encoded polyline is not being rendered correctly. How is your code handling that?
example using the geometry library decodePath function
Looks to me like Google broke their polyline encoding.
If I paste it into here (which admittedly doesn't expect polylines, it expects polyons)
I need to escape the "`", change:
{pazFraw~L|#|#f#^`#N\\?XIx#a#n#[
to:
{pazFraw~L|#|#f#^\`#N\\?XIx#a#n#[
to make it have a more reasonable shape.
I use such urls like:
http://maps.google.com/?saddr=546%206th%20Avenue,%20New%20York,%20NY%2010011%20(Sixth%20Avenue,%20New%20York)&daddr=W%20103rd%20St,%20New%20York,%20NY%20&dirflg=r
But it returns full html page. Does anybody know how to get such info in json or xml or any parsable format?
I need public transit.
You just add &output=json to the end of the url.
I'd like to extend Mathias's answer a little bit.
There's no official Google Transit API at the momemnt. Transits are provided by agencies, and most of Transits are not public. So, Google is not allowed to open them as API.
You may try to consume the "unofficial" data using your link + "&output=json".
However, the result won't be a valid JSON. Instead, that's something, that can be easily converted to a JavaScript object. (The differences are: there is no quotes around property names,
the strings are not properly encoded etc.)
Imagine you got this JavaScript object. However, it won't allow you to easily get the structured route details. Object's properties contain the route points coordinates, but no descriptions. The only place where the descriptions may be found is 'panel' property, which contains a chunk of HTML text (you may find a link to the sample of HTML in my blog post)
So, you'll have to convert this HTML into XML (X-HTML) and then build the parser of this XML to get the essence data of a trip.
Seems like a bit of overkill to me. Having in mind, that "unofficial" API may change in the future, including slight changes in 'panel' HTML structure that will kill your parser.
#MathiasLin, how did you overcome this?
Google Maps Javascript v3 and the Directions Web Service now has this capability as per :
https://googlegeodevelopers.blogspot.in/2012/06/public-transit-routing-and-layer-now.html
Update:
Latest server side API docs:
https://developers.google.com/maps/documentation/directions/get-directions
Re choosing public transport - it seems that it defaults to public transport now (at least when I use it).
Changing the last URL parameter, dirflg=r, into dirflg=w switches the directions to walking mode.
Plus see:
Walking, bicycle and public transport directions with time required in each mode , iPhone
for more detail about the parameters.
Google direction API response is in HTML, JSON format please check https://developers.google.com/maps/documentation/javascript/directions?hl=lv
& section 'The DirectionsResult Object'