Reputation: 3
I use Google places api as demonstrated here https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete. My code is as follows:
var options = {
componentRestrictions: {country: "gr"}
};
var element = document.getElementById('place');
var placeAuto = new google.maps.places.Autocomplete(element, options);
google.maps.event.addListener(placeAuto, 'place_changed', function() {
var place = placeAuto.getPlace();
if (!place.geometry) {
return;
}
$('#lat').val(place.geometry.location.lat())
$('#lon').val(place.geometry.location.lng())
});
Places suggestions are different on mobile than those on desktop application. Is there any way to get the same results?
Upvotes: 0
Views: 438
Reputation: 2518
You're not specifying a location bias, so the Google Places API will attempt to guess the location from the IP address:
Note: If you do not supply any bounds or a map viewport, the API will attempt to detect the user's location from their IP address, and will bias the results to that location. If you would prefer to have no location bias, set the bounds to encompass the whole world: (-90,-180),(90,180).
So provide an explicit location and you will see consistent results independent of IP address.
Upvotes: 1