FAQ Q281: I have resources in a number of geographic locations. Can my customers do a geolocation search with planyo?

Yes, this is supported, for both single sites and metasites. Your visitors can use the geographic location as one of the search criteria. The way this works is that they enter a location and a maximum radius. Only the resources within this distance will be returned in the results. The location can be entered either as the current position (this will work very well with mobile devices/tablets but may also work with desktops) or by clicking on Choose on map which opens a lightbox where the customer can either enter the address into an address box or they can also click on the map to specify the location visually.


Search form including the geolocation feature

As an extra feature, in the search results you can show all results on a map. To do this, go to the search results template and add the $(goog_map_results) tag (or another similar map tag).


Search results including a map

In order to use this feature, you must first go to Settings / Site settings / Custom resource properties and add a new item of type GPS coordinates. When adding it, make sure you specify the possible distances for the customer to choose from (in the field Possible values. This is a comma-separated list. Use the km suffix for kilometers and m or miles for miles, e.g. 10km, 50km, 100km. The last setting you can optionally fill out when adding the GPS coordinates property is a Google Maps API key for the search. You should get a free API key (called "browser key") from Google and enter it here. We use the Google Maps JavaScript API v3 service for which you can get the api key at https://console.developers.google.com/. You can read more about the API keys from Google here.


Adding a GPS coordinates property in Custom resource properties

Once you enter the new resource property definition into your planyo site or metasite, you should specify the geographic location of all your resources. You can do this in each resource's settings but it's more convenient to click on Batch edit property.

Now the last thing to do is add the geolocation criterium to your search box. Please follow this tutorial to find out how to add custom resource properties to your search box, whether working with a search box widget or the search mode in the planyo plugin.

In your search results template, you can use the tags $(geolocation_distance) and $(geolocation_distance_miles) to show the distance from the location chosen for each of the results. It's also possible to sort the results by this distance.
Back to Frequently Asked Questions