Friday, November 15, 2013

Location Biasing in the Google Maps API


Everyone hates stupid map search results. However map search results can be very hard to get right - there are a lot of towns and streets in the world with the same names.

If your application continuously directs users to the wrong location then you are very quickly going to lose those users. If I live in San Francisco and I search on a map for Broadway Street the chances are I'm not looking for the Broadway Street in Pearland Texas but for the one in San Francisco.

Therefore one way that you can improve search map results for the majority of users is by using location biasing. Thankfully you can now add location biasing to your Google Maps search using Google Places API Autocomplete.

Autocomplete in the Google Places API now automatically biases results towards the user’s location based on the user’s IP address. Therefore the closest locations to the user will appear at the top of the autocomplete suggested addresses.

However there may be cases where you don't want to bias search results based on the users location. For example if your application is a map of the most visited San Francisco tourist locations you might want to restrict search results to the San Francisco area. Using Location Biasing in the Places API you can also bias results to a specified area by defining a location and a radius. This ensures that the Place Autocomplete service preferences results within that circle. You can also use the components parameter to filter results to show only those places within a specified country.

Location biasing isn't a perfect solution to map search results and you may not want to use location biasing in your maps. If that is the case you can effectively turn it off in the Places API Autcomplete search by setting the location to '0,0' and radius to '20000000' (20 thousand kilometers), so that your results encompass the entire world.
Post a Comment