I have address(city,state,country,zip) and want to get TimeZone , latitude and longitude in single Google API call , i see google provide TimeZone api which accepts latitude and longitude and returns TimeZone but that requires two api call , first is to get location ( lat/lng) and second call to get TimeZone from location , not sure if google provide such api which can solve this problem in single call.
I believe you can at least get the number of minutes this place's current timezone is offset from UTC together with its coordinates using Place Autocomplete. You can look for the logs 'utc_offset' under 'result' property.
The response includes the following:
geometry: The place's geometry-related information. This includes:
location provides the latitude and longitude of the place.
viewport defines the preferred viewport on the map when viewing this place.
utc_offset: contains the number of minutes this place’s current timezone is offset from UTC. For example, for places in Sydney, Australia during daylight saving time this would be 660 (+11 hours from UTC), and for places in California outside of daylight saving time this would be -480 (-8 hours from UTC).
You can use Places Autocomplete as #rafon said. But you should use setFields method and add utc_offset_minutes.
Like that autoComplete.setFields(['utc_offset_minutes'])
You can not get utc_offset_minutes from geocoding api.
Related
Is there a way by using azure-maps or google-maps to get from longitude and latitude all postal codes and municipalityes that are in range of X kilometers?
I've yet checked the Get Search Nearby of azure, but it returns only points of interests and it is not possible to specify in the API a range in which the data should be get.
In Azure Maps, getting all postal code/municipalities within a specified distance of a location or within an area is not currently available. However, this is something being investigated as a possible future service. Consider submitting this as a feature request here: https://feedback.azure.com/forums/909172-azure-maps
I don't believe Google Maps has any such service either.
I want to find a travel time (including traffic) between two addresses.
Inputs - origin, destination, arrival time, mode of transportation, traffic model (pessimistic, optimistic, best guess)
Output - Travel time
It looks like the Google Distance Matrix API is the API I should be using for this except that I am not able to add an input of arrival time for driving. I am prompted to add a departure time. When the transportation mode is transit I am able to enter an arrival time.
Is this a limitation of the distance matrix API? Is there a paid for version or another work around for this?
As of today (January 6, 2019) arrival time for driving is not supported. Here is the relevant portion of the help file for the API's directions method:
:param arrival_time: Specifies the desired time of arrival for transit
directions. Note: you can't specify both departure_time and
arrival_time.
:type arrival_time: int or datetime.datetime
The key being that arrival time is only used for transit directions and not driving directions. When I use mode='driving' and an arrival_time, I get and error that ends with:
raise googlemaps.exceptions.HTTPError(response.status_code)
googlemaps.exceptions.HTTPError: HTTP Error: 400
When I change this to a departure_time, the function call works just fine.
Explicit answers to the questions:
Is this a limitation of the distance matrix API?
Yes.
Is there a paid for version or another work around for this?
No. Your only option is call the API with a guess for the departure time, find the travel time and then iterate until the arrival time converges.
instead of using the google direction matrix try to use google map direction API, it will give you best results with the time distance and traffic update, see GOOGLE MAP DIRECTIONS API docs.
You need to use the Google map distance matrix API, which get input as source latitude, longitude and destination latitude, longitude. It will return the json file contains the source address, destination address, distance in km and time with traffic and without traffic.Below is link follow it
https://developers.google.com/maps/documentation/distance-matrix/intro
There is also a limit of this API, it allows only 2500 hits per day
We have an API which looks up the lat / long of an input address using the Google geocoding API. The location of the response of that is then fed to the Google Timezone API.
As it turns out though, there are some locations which, while they do return a valid result from the geocoding api, return a ZERO_RESULTS error from the timezone API. Some of these are e.g. 690091,Vladivostok,Russia, or country BL (Saint-Barthélemy).
Geocoding request:
https://maps.googleapis.com/maps/api/geocode/json?key=API-KEY-HERE&components=country%3ARU&address=690091%2CVladivostok
Timezone request:
https://maps.googleapis.com/maps/api/timezone/json?key=API-KEY-HERE&location=43.140489%2C131.858103×tamp=0
This isn't listed in the documentation as a possibility.
My main question: is this a known problem with either timezones in general, or the google timezone API in general?
I'd expect that all valid lat / lngs would have a timezone, and with some googling I don't see any cases of a location not having a timezone. The Vladivostok example points to somewhere in the sea according to google maps, but Saint-Barthélemy points right on the island (api, maps).
Edit: As it turns out, I didn't read: the timezone api states "Note that time zone data may not be available for locations over water, such as oceans or seas." Does anyone know what the reason behind that is? Weirdness with country borders and international waters?
The coordinate (43.140489,131.858103) that you apply in Timezone API appears to be located in the water.
Please have a look at this position in Geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D43.140489%252C131.858103%26nfw%3D0
The green cross shows the position of the coordinate.
Timezone API doesn't return results for waters.
I have seen very similar issues in the public issue tracker:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=10885
https://code.google.com/p/gmaps-api-issues/issues/detail?id=10762
You should apply latitude longitude that is located on the land and additionally you can comment on the issue 10762. I believe this is a good feature request to have a TimeZone API within the waters owned by a country.
I'm using Google places API to check the places nearby and let the user pick one. Everything works fine but I'm having location issues, If I send the longitude and latitude to the api call for a search, for example "McDonalds" I get results in CHICAGO instead of San Francisco...
Any Idea what maybe happening? This is my query:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=mcdonald&types=establishment&location=37.76999,-122.44696&sensor=false&key=hereIsWhereMyKeyGoes
This is Google's documentation: https://developers.google.com/places/documentation/autocomplete
Thanks!
You need to define the radius to search within.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=mcdonald&types=establishment&location=37.76999,-122.44696&radius=20&sensor=false&key=hereIsWhereMyKeyGoe
I used to have a similar problem with results from Chicago so that must be some sort of default area to search in. To search near a location you must supply the location and radius parameters.
I am using Google's reverse geocoding functionality with the maps api v3 to retrieve postal addresses for latitude longitude (when dragging a marker around a map).
This is a UK application only, and part of the system requires a full, or near full, postcode to process correctly. However the reverse geocoder regularly returns just the part of the postcode - for example "GU3", even when the actual address returned appears to be complete - for example including street and house number.
Is there anyway, preferably google but otherwise if not, of 'snapping' the address to the nearest full postcode?
I'm aware similar functionality exists for snapping to the nearest panorama view, but there appears to be no equivalent for postcode.
The UK post code database is available for download from the Ordnance Survey open data
www.ordnancesurvey.co.uk/opendata
Alternatively you can use a service like uk-postcode.com to return the closest post codes to a location
See the example at https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-reverse
Try a UK location like 51.436951, 0.058112.
The results include an address_component of postal_code, "SE9 3AG".
It may be necessary to geocode the address you're given and then reverse-geocode the results in order to get the postcode. But it is possible.