Google Maps Javascript API, DirectionsService, list of countries - google-maps-api-3

I am creating a route using google.maps.DirectionsService.
What would be the best method to get the list of countries the route goes through?
I can't find this info in the DirectionsResult https://developers.google.com/maps/documentation/javascript/reference#DirectionsResult

Each route from the routes array have a overview_path array with all the coordinates. You can geocode each of this coordinates and get the country of it (remember the limitation of geocoding calls!). Isn't the best solution but....

Related

Mistaken results from Google Geocode API

I need to request in google geocode api to get geocodes. I've city, district, number and state and I'm requesting
https://maps.googleapis.com/maps/api/geocode/json?address={street}, {number} - {district}, {city } - {state} ... `
I'm sending a city, but google is returning to another city.
is there a way to force-find geocode in the city that I'm sending?
Or force parameters at query, like:
https://maps.googleapis.com/maps/api/geocode/json?city={city}&state={state}
It doesn't look like Google Maps supports passing in structured address data, only address strings. Consider taking a look at Azure Maps, it has a service where you can pass in each part of your address as separate parameters. This will likely be more inline with what you are looking for. Here is the service documentation: https://learn.microsoft.com/en-us/rest/api/maps/search/getsearchaddressstructured
Here are some related resources:
https://azure.com/maps
https://learn.microsoft.com/en-us/azure/azure-maps/
https://azuremapscodesamples.azurewebsites.net/index.html

Batch Geocoder API, how to get extra road attributes

Using the Batch reverse-Geocoder API, is it possible to get additional road attributes, like:
SpeedLimit
LinkFlags
SideOfStreet
Thanks!
For getting the side of street you have to first add parameter
locationattributes=mapReference
and request the output field
mapReferenceSideOfStreet
in the outcols parameter.
Example:
&locationattributes=mapReference&outcols=city,district,street,mapReferenceSideOfStreet

Google Maps API queryautocomplete location parameter doesn't work

I'm trying to use "location" parameter for queryautocomplete command in Google Maps API. But whatever coordinates I give, it returns the same results. I just need to get search suggestions of places nearby the location coordinates. Here is query example:
https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=%D0%BF%D1%80%D0%BE%D1%81%D0%BF%D0%B5%D0%BA%D1%82&key=*******&location=53.2415041,50.22124629999996&language=ru
**** is key ID
Does anybody know how to solve it?
дружба
define a radius too.
Currently you get a place in moskow as first result, although the location is in samara(but the returned places are more prominent , e.g. mir prospect in moscow)
Sample request with radius a radius of 50km:
https://maps.googleapis.com/maps/api/place/queryautocomplete/json?input=%D0%BF%D1%80%D0%BE%D1%81%D0%BF%D0%B5%D0%BA%D1%82&location=53.2415041,50.22124629999996&radius=50000&key=yourkey
First result: lenin prospect, samara

Store Locator API + Geolocation

I am trying to create a Store Locator with the Google API, very similar to the one in the Google examples here:
http://storelocator.googlecode.com/git/examples/panel.html
However I've hit a wall trying to get the Store Locator API to get the user's position through Geolocation, so when I click on Get Direction in the infowindow I get directions to the user position; instead of having to type my address in the: Where are you? Panel box.
In the documentation what I have seen is that geolocation is a boolean in the View Option that is set to True by default. But this does not solve my problem.
Does anyone have any idea on how to do this?
seems that the googlecode page you said is no longer exist. So I can't give any further insight about what you want to make.
However, by your description, Luckily I made similar site few months ago. It is on Grocery Store Near Me .
The concept of Geolocation is an HTML5 (actually W3C) Geolocation API which is now already embed in most modern browser. It is an API which you can obtain user's location (latitude, longitude, altitude, and accuracy).
you can call it with simply
navigator.geolocation.getCurrentPosition(success, error, geo_options);
Success and error is a callback function in which you can define.
In my case, the function looks like these
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// use the lat and long to call function to fetch an API through AJAX
fetchStoreData(latitude, longitude);
}
In the Store Locator schema (like mine in Grocery Store Near Me), Geolocation is used to obtains user lat and long. The lat and long, then send to server via AJAX to get data about nearby store location.
The server serve an API in which accept lat and long as parameter, then fetch the store data (either using database, or other external API like foursquare), then you can display it either on list, or on a maps.

Acquired the building name using GPS Coordinates

I am writing an app to use GPS coordinates obtained by the cell phone itself to retrieve the building name of that location.
For example, if I use this http URL to request with Google Place API:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&radius=10&sensor=false&key="YourKey"
I can only get the street name of this coordinate through this.
But if I type "40.805112,-73.960349" in maps.google.com. I can get the exact building name. SO I was wondering how can I use Google Map API to obtain the building name I want.
Thank you very much about this!!!
The first result in the request you provided contains "name" : "Church of Notre Dame", isn't this what you are looking for?
A better request if you are only interested in the place name at this location would be to use the rankby=distance parameter instead or radius and to filter by type=establishment:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&rankby=distance&types=establishment&sensor=false&key=YOUR_API_KEY
This would return the closest place at the given location.

Resources