Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Geocoding API, feature from the API missing in their JS api (?)

The problem is simple, in the documentation for the Geocoding API they say component filtering exists. (Source: https://developers.google.com/maps/documentation/geocoding/)

However, if I look at the JS documentation (https://developers.google.com/maps/documentation/javascript/geocoding), it doesn't seem to be implemented. I do however remember that google earlier used to have features implemented but not written about in their API, so I wonder if anyone knows how to achieve component filtering with the Google Maps Geocoding API?

Thanks!

like image 330
Alexander Kuzmin Avatar asked Jun 19 '13 21:06

Alexander Kuzmin


People also ask

Why is Google Maps API not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.

Is Google's geocoding API free?

The Geocoding API uses a pay-as-you-go pricing model. Geocoding API requests generate calls to one of two SKUs depending on the type of request: basic or advanced. Along with the overall Google Terms of Use, there are usage limits specific to the Geocoding API.

Is the Google Maps JavaScript API free?

The Maps JavaScript API uses a pay-as-you-go pricing model. Maps JavaScript API requests generate calls to two different SKUs depending on the type of request: map loads or panoramas. JavaScript services are priced separately from JavaScript native SKUs.


1 Answers

The documentation seems to of implemented it now. Either way, here is the code:

geocoder.geocode( 
      { 'address': address, 'componentRestrictions':{'country':'GB'}}, 
function(results, status){
...   
});

Used to restrict results to a specific area. A filter consists of one or more of: route, locality, administrativeArea, postalCode or country. Only the results that match all the filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests. See Component Filtering in the Geocoding web service for further details.

like image 148
rickyduck Avatar answered Sep 22 '22 01:09

rickyduck