Good evening, my doubt refers to the following case:
I'm working with the google maps API V3, and I use services like Places, Geocoder and Matrix Distance. But I have a huge problem to return the user's current location ID (returned using the geolocation of maps), however it only returns me the Latitude and Longitude of the location, or I am not aware of returning other information.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
posAtual = { // recebe ltd e lngt
lat: position.coords.latitude,
lng: position.coords.longitude
};
var openedMarker = posAtual.lat + "<br>" + posAtual.lng;
var markerAtual = addMarker({coords:posAtual, content:openedMarker}); // define o local do marker
map.setCenter(posAtual); // centraliza posição atual se permitido pelo browser
}, function() {
handleLocationError(true, markerAtual, map.getCenter()); // se der erro volta pra localização antiga
});
return true;
} else {
// Browser doesn't support Geolocation ou NÃO foi aceito pelo user
handleLocationError(false, markerAtual, map.getCenter());
return false;
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) { //Erro que sera exibido caso falhe
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}
This is the code I use to fetch the current position, I tried to search the google documentation or even here in the OS, but without much success.
The API returns the Site ID whenever it is searched, in this case, with a place autocomplete field. But it does not happen when searching for a Latitude / Longitude coordinate.
Thank you for your attention.