Google Map places API - search address by country and code postal

3k views Asked by At

Please I want to use the autocomplete places API to get address based on country 'fr' and postal code like 87000

This is what I have done:

function initialize() 
{
   var quartier = document.getElementById('quartiers');

   var request = {
    types: ['geocode'], 
    componentRestrictions: {country: 'fr'}
   };

   var autocomplete = new google.maps.places.Autocomplete((quartier), request);

   google.maps.event.addListener(autocomplete, 'place_changed', function(data)
   {
      //some code here
   });
}

This one works great for country, but I don't know how to get it working with a specific postal code like 87000.

Any ideas?

1

There are 1 answers

0
Joys On

Hi try change in this line

types: ['geocode'], 

for this

types: ['regions'], 

Regards