Give the gift of Drupal. All merchandise is 50% off through 2016.
Openlayers Locator is a feature module that sets up the basic functionality for a map based proximity search. It creates a content type "Location"; a view to list all these locations, a map and the search option; as well as a link to it in the main menu.
This is a screenshot of an example proximity search results.
Installing and enabling the required modules
- Install all required modules listed on the Openlayers Locator project page.
- Enable the Openlayers Proximity feature module either from the modules admin page (admin/modules) or the features admin page (admin/structure/features).
Once the feature is enabled, a new content type and the proximity search view are created and configured for you.
Create geolocated content
- Go to the 'add content' page and choose to create a new Location.
- You will find the usual title and body fields plus an address field set, fill it in and save.
- If the geolocator module was able to geolocate your address it will be shown in a map in the node page.
- Add several more Location nodes (choose near-by addresses so you can find several of them within a few kilometers range.
Conduct a proximity search
- You will find a Locator menu item on your primary menu: click on it.
- You will find all your nodes la new conteisted and a proximity search box.
- Type in the city name (it does seem to work better with city names than postal codes, at least for Spain) and click search.
If some nodes are within your range, you should see a table and a map with the corresponding results.
What is this feature doing?
Go to admin/structure/features and click on the link for the OpenLayers Locator feature. It will show all the dependencies enabled on the left side and the views and content types on the right.
This feature provides:
- The Location content type: ol_locator_location: This is the content type which is configured to store your location based on an address. It uses geofield, geocoder and addressfield modules for that purpose. You can learn more about how to configure this three modules together in the Getting Started with OpenLayers in Drupal 7 guide.
- The node view OpenLayer map: ol_locator_node_map: You will find this is the OpenLayer map in your Location node view pages. It is configured as the format widget for the geofield module in the Location content type (have a look at admin/structure/types/manage/ol-locator-location/display)
- The search OpenLayer map: ol_locator_proximity_search_map: This is the OpenLayers map that shows your nodes in the search results. It is used by the search view (see below).
- The search view: ol_locator_proximity_search: This is the view page where all the fun happens. It basically uses the OpenLayer search map (see above) for the display and an exposed filter provided by the OpenLayers proximity module to filter out the nodes outside your range.
- The table is an attached display.