Reputation: 4277
I'm trying to use Google Places in my Angular app to return to the user in an autocomplete input only address result which are in a radius from a location, so from the documenentation i should use parameters as location
radius
and strictbounds
.
To use autocomplete i'm using the following ngx library but the issue is that after setting all the parameters in the options when i'm trying to write a certain address firstly i get only the one that are in the range BUT if i anyway try to write one out of range or even another city that is out of range it will still return that values and i would prevent it.
Here are my autocomplete options
addressOptions = {
types: ['address'],
componentRestrictions: {
country: 'it'
},
location: new google.maps.LatLng( 44.7179422, 10.5465457),
radius: '1000',
strictbounds: true
};
<input
type="text"
class="form-control"
required
placeholder="es. Via D'israeli"
formControlName="indirizzo"
ngxAutocomPlace
[options]="addressOptions"
(selectedPlace)="addressChange($event)"
/>
Upvotes: 2
Views: 1094
Reputation: 128
mytyuk, it seems strictBounds
will only be take into account when passing bounds
property (https://developers.google.com/maps/documentation/javascript/places-autocomplete)
strictBounds is a boolean specifying whether the API must return only those places that are strictly within the region defined by the given bounds. The API does not return results outside this region even if they match the user input.
Upvotes: 1