Add Google Maps location search functionality for any post type.
Why use Simple Locator?
Simple locator is ideal for developers who are looking for a way to implement location search for any post type. Simple locator is different in that it allows the selection of any existing custom fields for use as the geocoded data sources.
Don’t have an existing post type with geocoded latitude and longitude fields? Simple Locator includes a default “Locations” post type with fields for latitutde, longitude, address, phone number, website, & more. This post type’s name and labels are configurable through the plugin settings.
Simple Locator also offers developer-friendly options for adding custom Google Maps styling. Select from an existing list, leave the default styles, or add your own JSON styles.
Using Simple Locator
For more information visit locatewp.com.
Important: Simple Locator requires WordPress version 3.8 or higher, and PHP version 5.4 or higher.
The shortcode to display the form and results is [simple_locator]. There are several options available for customizing the form and results:
Visit locate.wp for more detailed information.
Options include the title, distance options, and the map height. To use the widget outside of a predefined sidebar area, use the following function in your template, as outlined in the WordPress documentation. The widget name is SimpleLocator\Widgets\Form (must include namespaces).
To enable Google Places autocomplete in the search form, visit Settings > Simple Locator > General, and select the “Enable Autocomplete in Search” option. Your form will now include an autocomplete dropdown populated by the Google Places API.
By default, a map of the location is added to the content on singular views. To remove this feature, update the setting under Simple Locator > General Settings.
A number of JavaScript functions are provided to extend and customize the map results. Visit locatewp.com for a list and usage details.
For a complete description of available filters and example usage, see the plugin website.
simple_locator_form($output, $distances, $taxonomies, $widget)
– Customize the search form HTMLsimple_locator_result($output, $result, $count)
– Customize the result output within the result listsimple_locator_infowindow($infowindow, $result, $count)
– Customize the display of results within the Google Maps infowindowsimple_locator_post_fields()
– Add additional fields to the search parameters (field names for $_POST data)simple_locator_sql_select($sql)
– Add additional fields to the SELECT sql query during searchsimple_locator_sql_join($sql)
– Join additional fields in the sql query during searchsimple_locator_sql_where($sql)
– Add additional WHERE parameters to the sql query during searchsimple_locator_form_in_results($display_form)
– Whether to show the form in results (bool)simple_locator_all_locations_text($text)
– Filter the text output of “All Locations”simple_locator_map_pin_single($html)
– Filter the single view map pinsimple_locator_js_map_options($options)
– Filter the Javascript options passed to Google Maps for map displaysimple_locator_autocomplete_js_options($options)
– Filter the Javascript options passed to the Google Maps Autocomplete APIsimple_locator_form_taxonomies($taxonomies)
– Filter the taxonomies displayed in the search formDisplay a simple, AJAX-enabled locator form using a shortcode or widget.
Form results load without page refresh. Customize the results & map containers if needed.
The included "location" post type includes custom fields specific to locations.
Includes options for Google Maps API Key, measurement unit (miles/kilometers), custom map pin image, whether to output the included CSS, whether to display the map in the specified post type's singular view, and option to add a geolocation button on enabled devices.
Use the included post type and latitude/longitude fields, or specify your own existing combination of type and fields. Works with Advanced Custom Fields. Ideal for developers looking for a customizable location search.
Choose from a list of pre-defined map styles, and optionally customize the Google Maps options object.
Or, paste your own JSON formatted styles.
Optionally show a default map on page load, with a custom location. Additionally, results can be set to show automatically on page load if the user's device or browser has geolocation capabilities. If the user doesn't, or they deny location access, the default map will show if set to.
Configure results display by adding custom fields from the chosen post type plus post data including the title, permalink, excerpt and thumbnails.
Import locations in bulk from a CSV file. Locations will be automatically geocoded using the Google Maps Geocode API (Import functionality requires PHP version 5.4+ and a valid Google Maps API key with the Geocoding API enabled).
As of version 1.2.0, Simple Locator includes a bulk CSV data importer. If you have your location data available in CSV format with separate address, city and state/province columns, you may use this tool to import your locations as posts and geocode the locations automatically. The Google Maps Geocoding API limits requests to 2500 per day, so if your file contains over 2500 rows, it may take multiple days to complete the import. See the Simple Locator Website for details on importing locations.
The Google Maps Geocoding API limits requests to 5 per second, and 2500 per day. The import process is throttled to comply with the API limits. See the Google Geocode API documentation for more information.
Import progress is saved, and you may always come back and continue at a later time. If you received an API limit error, you’ll need to wait 24 hours before continuing the import. If you attempt to continue after receiving this notice, your API key may be disabled by Google for violating their API terms. You may check your request usage in the Google Developer Console. If you receive a 500 error from Google during the import, try refreshing the page and continuing the import. If the issue persists, check the last import row for formatting errors (the last import row will be displayed on page refresh).
The Google Maps Geocoder could not locate the address. Check the corresponding CSV row number for formatting errors.
Your API key must be public, and have the Geocoding API enabled. To enable the API, visit your Google Developer console, and enable both the “Javascript API v3” and the “Geocoding API”. You may also check your API usage through the developer console.
All geocoding and mapping functionality takes advantage of the Google Maps Javascript API V3. Unexpected changes in the API service may effect plugin functionality, but any changes will be monitored and addressed as needed.
Use of the Google Maps API requires that the data be displayed in a Google map. Hiding the map violates the API licensing.
Several Javascript callback functions are provided for key events in search, and map rendering. To learn more about these callbacks, visit locatewp.com.
No. If an existing post type is chosen as the search term, there must be preformatted latitude and longitude fields associated with each post. Geocoded fields must be formatted using the degree format. All new posts under the “location” post type are geocoded on save.
The search form uses the Google Maps API geocoding service, which offers reliable data throughout the world. Use of the API may change depending on your specific location. Localization is possible using the provided POT files in the /languages folder. To toggle between miles and kilometers, visit Settings > Simple Locator.
Pagination is available in non-AJAX forms. To disable AJAX form submission, use the ajax=”false” shortcode option. To limit results per page, use the perpage=”15″ option. NOTE: custom map/results containers are not available in non-AJAX forms.
As of version 1.4.0, the Google Maps options object is customizable. To customize the options, visit settings > Simple Locator > Map Display. Check the box to enable custom map options and enter them. This MUST be a properly formatted Javascript object. Think of this as if you were writing your own Google Maps implementation and needed to pass options. Also note, enabling custom options will override any options set in shortcodes.
This plugin relies on the Google Maps Javascript API. Please refer to the API documentation regarding commercial use and licensing.