There are component restrictions for the google geocoding api.
admininstrativeArea, country, locality, postalCode, route
can I use any of these to filter by city and town? So that I don't get back a country or state?
Something like
this.geocoder = new google.maps.Geocoder();
this.geocoder.geocode({
address: this.registerForm.get('city').value,
componentRestrictions: {
country: 'US',
locality // not sure here
}
},
(results, status) => {
if (status === google.maps.GeocoderStatus.OK) {}
}
I can do it with google maps autocomplate!
this.autocomplete = new google.maps.places.Autocomplete(this.element, {
types: ['(cities)']
});
https://maps.googleapis.com/maps/api/geocode/json?components=locality%3AHouston%7Ccountry%3AUS&key=YOUR_API_KEY
seems to return city 'Houston, TX, USA'. – Elenaelenchus