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
- Add locations. This can either be the included “locations” post type or an existing custom post type with existing geocoded fields. Locations can also be imported in bulk using the included CSV importer.
- Use the Shortcode [wp_simple_locator] or Widget to display a search form. The shortcode offers more options for map and form customization.
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:
- distances – A comma separated list of numbers used to customize the list of available distances to choose from in the form. Defaults to 5,10,20,50,100
- mapheight – The height of the map in pixels. Defaults to 250.
- mapcontainer – The unique ID of a custom container in which to load the map (ID parameter of HTML element).
- resultscontainer – The unique ID of a custom container in which to load the search results (ID parameter of HTML element).
- buttontext – Text to display in submit button. Defaults to “Search”.
- addresslabel – Customize the address form label
- mapcontrols – Hide or show the map controls
- mapcontrolsposition – Google Maps formatted position for map controls (ex: TOP_LEFT)
- showgeobutton – Whether to show or hide the “Use My Location” button. This button is hidden on sites that do not include an https connection. Defaults to false.
- geobuttontext – Customize the text content of the geolocation button if shown. Defaults to “Use My Location”.
- ajax – Whether to submit the form with an ajax request. Defaults to true.
- formmethod – The method of which the form submits. Default to “post”. If using a GET method with a non-ajax request, a results page must be specified.
- placeholder – Customize the search input placeholder text. Defaults to “Enter a Location”
- noresultstext – Customize the text displayed if no results are returned. Defaults to “No results found”.
- ajax – To disable AJAX form submission, use ajax=”false”. NOTE: custom map/results containers are not available for non-AJAX forms (added in v1.3.0)
- perpage – Used in conjunction with AJAX option. If a perpage option is included in a non-AJAX form, the results will be displayed with simple pagination, limited to the number per page specified. (Ex: ajax=”false” perpage=”15″). Pagination is not available with AJAX forms.
- resultspage – If a non-ajax form is being submitted (see ajax option), a separate results page may be specified.
- taxonomies – To include taxonomy filters in the search form, use a comma-separated list of taxonomy names/slugs. The form will include select menus for each of the taxonomies specified. (AJAX only)
- taxonomy_field_type – If taxonomy fields are displayed, the field type may be either “select” or “checkbox”. Defaults to “select”.
- allowemptyaddress – Set as “true” to allow empty address fields to be submitted (useful for returning all locations regardless of the user-specified location)
- showall – Whether to show all locations on page load. Defaults to false.
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.
Extending & Customizing Map Display
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 HTML
simple_locator_result($output, $result, $count)– Customize the result output within the result list
simple_locator_infowindow($infowindow, $result, $count)– Customize the display of results within the Google Maps infowindow
simple_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 search
simple_locator_sql_join($sql)– Join additional fields in the sql query during search
simple_locator_sql_where($sql)– Add additional WHERE parameters to the sql query during search
simple_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 pin
simple_locator_form_taxonomies($taxonomies)– Filter the taxonomies displayed in the search form
- Upload simple-locator to the wp-content/plugins/ directory
- Activate the plugin through the Plugins menu in WordPress
- Click on the Locations Menu item to begin adding locations.
- To change the post type, geocoded fields, or map styles, visit Settings > Simple Locator
I have a LOT of locations. How can I get them imported in bulk?
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.
Why does importing take so long?
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.
I got an error during a large import. What do I do now?
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).
Why does “ZERO RESULTS” mean in the import error log?
The Google Maps Geocoder could not locate the address. Check the corresponding CSV row number for formatting errors.
Why isn’t my Google Maps API Key Working for the Importer?
What 3rd party services does this plugin use?
Can I hide the map, and only show text results?
Use of the Google Maps API requires that the data be displayed in a Google map. Hiding the map violates the API licensing.
How do I add custom functionality to the generated maps?
Is my existing data automatically geocoded?
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.
Does it work outside the United States?
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.
How do I paginate results?
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.
I’m a developer. How do I customize the map options?
Can I use this on a commercial site?
Contributors & Developers
“Simple Locator” is open source software. The following people have contributed to this plugin.Contributors
Translate “Simple Locator” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
- Adds marker clustering option, with optional setting to pass in custom Google Maps Renderer object
- Fixes bug that prevented taxonomy filters from applying in location searches
- Fixes bugs that were preventing ACF map field functionality from running correctly.
- Fixes bugs that were not allowing the selection of custom lat/lng fields in the plugin settings.
- Updates form to use API, with custom endpoints added for search and all locations queries.
- Adds map pin filter, enabling customization of map pins for each location result.
- Adds option to include the user’s search location as a pin, with option to customize separately from result pins.
- Adds a results page parameter to non-ajax forms, allowing the redirection of form results to a custom page.
- Adds a hookable action to display results, allowing for custom template placement of results in non-ajax requests.
- Adds pagination with results-per-page in ajax and non-ajax forms, configurable through shortcode parameters.
- Adds form method option in shortcode, allowing for either POST or GET form submissions on non-ajax forms.
- Adds Google places API autocomplete JS options (limit autocomplete suggestions to a specific type like cities, only show in specific countries).
- Updates text domain to follow WordPress guidelines (updated to match the plugin name).
- Adds multiple hooks throughout for even more customization flexibility.
- Replaces JS callback functions with document-level JQuery events. Previous callback functions have been deprecated and will be removed in a future version.
- Adds taxonomy field type option in form shortcode, enabling the use of checkbox or select elements in search forms.
- Updates core styles and loading indication.
- Updates plugin setting styles and layout.
- Adds taxonomy arguments to “all locations” shortcode. To limit by terms, include the taxonomy name with a comma separated list of term ids (ex: category=”4,5″).
- Adds post ids argument to “all locations” shortcode. To limit to specific ids, use a comma separated list (ex: ids=”3,4″).
- Adds “no locations found” argument to “all locations” shortcode.
- Adds “showlist” argument to “all locations” shortcode, which displays the list of locations underneath the map.
- JS completely rewritten for better extensibility and future enhancements.
- Adds option to import into non-public post types.
- Adds additional import options (expanded post data mapping, taxonomies, duplicate/missing record handling and more).
- Adds option to clear the search log.
- Adds option to specify a default distance in the form shortcode. Mark the default distance with an asterisk: Ex: distances=”5,10,20*,50,100″. (The “20” option would be selected by default).
- Adds option to show all locations by default, below the form (showall=”true”). Header text is customized using the showall attribute (showall=”Showing all locations”). Map centered to “default map location” if enabled in the plugin setting.
- Adds “mapheight” shortcode option to “all locations” shortcode.
- Adds pagination option for widget.
- Adds argument filter to location post type declaration.
- Updates Google Maps API requirement for new Google Maps Platform.
- Adds option to display a map in the admin listing view (post list table).
- Adds option to place built in location fields in Advanced Custom Fields tab if ACF is enabled and tabs are assigned to the post type.
- Updates included Guzzle dependency to version 6 (resolves php 7.2 error).
- Adds CSV export option to export locations to CSV files, with the ability to save and load export templates.
- Adds location quick edit in admin post_row_actions, enabling quick location edit capabilities with geocoding. Displays if using the included Simple Locator address fields.
- Adds Google geocoding API test functionality to import to determine if there are errors with the API key provided.
- Bug fix where previously entered location post meta could not be removed.
- Pagination added to search log.
- Search log (list & map view) added along with filters and CSV export. History save must be enabled to view the search log.
- Fix in importer CSV upload that was preventing some csv formatted files from being uploaded
- Error handling added for missing API key on post edit screen.
- Option added to store user searches in the database
- Bug fix where post data not being reset in all locations shortcode
- Bug fix in all locations map, where custom JS options weren’t being applied
- Infowindow filter applied to all locations shortcode
- Callback functions added for all locations map load and click events.
- Importer improvements: Check added for existing location based on title
- Shortcode option added to customize results wrapping element.
- Bug fix for custom results limits not saving.
- Bug fix where SQL JOIN limit being exceeded on some servers (Thanks to Jeff Dreher)
- Bug fixes in Widget display
- PHP 7 bug fixes (Thanks to Loic Froidmont)
- Compatibility tested with WordPress 4.4
- Bug fix in single location shortcode
- Bug fix where multiple instances of the same location being returned on certain hosts (thanks to Christine McDermott for bug tracking help)
- Minor admin bug fixes
- Filter added for customizing infowindow content in map results (Contributed by Scott Polhemus)
- Filter added for customizing form HTML (AJAX only)
- Filters added for customizing SQL queries
- Shortcode option added to include taxonomy filters in search form (AJAX only)
- Shortcode option added to allow empty address field (returns all results)
- French Translation (Thanks to Khelil Benosman)
- Partial Dutch Translation (Thanks to Kristof De Loof)
- Option added to enable/disable the Google Maps API from being enqueued in the admin area (separate from front end)
- Customizable Map Options – Ability to customize the Google options array added. Visit settings > map display. To enable custom map options, check the appropriate box and enter a properly formatted Google maps options object. Important: If custom map options are enabled, options specified in shortcodes will be overwritten.
- Bug fix – fatal error thrown on some sites when attempting to activate without Advanced Custom Fields installed.
- Bug fix – error when saving a location using an Advanced Custom Field Google Map field with the included fields visible.
- Important: PHP version 5.4+ is required to run version 1.2.0 or higher. To use Simple Locator with PHP version 5.3, version 1.1.5 should be installed. Updating to a newer version on servers running older versions of PHP will result in an error.
- Option to enable Google Places autocomplete on search form added. Visit the plugin general settings to enable autocomplete. Customize the placeholder text using the new shortcode option: addresslabel=”Enter Your Location”.
- Ability to drag map marker to save custom location added on post entry screens.
- Advanced Custom Fields Google Map Field integration. If you are using a post type with an associated Google Map field, you can now set the latitude and longitude fields to be populated from that field when saving posts. Visit the plugin post type settings to enable the feature. A map field must be associated with the selected post type for the setting to be visible.
- Option added to hide the included custom meta fields from the post entry screen.
- Option added to customize no results text in shortcode. Use the option noresultstext=”Your Custom Message” to display a custom message.
- Non-AJAX option added to the form shortcode. To disable AJAX form submission, add the shortcode parameter ajax=”false”. When using the non-ajax form option, and additional pagination parameter is enabled. Use the parameter perpage=”15″ to designate how many results should show per page.
- Importer bug fix – API key for Geocoding saved separately as server key.
- Google Maps Import over HTTPS – Fixes issue on sites running HTTPS
- CSV bulk importing is now included for importing and geocoding locations. PHP version 5.4+ is required for import functionality, as well as a valid Google Maps API key with the Geocode API enabled. See the Simple Locator website for more details.
- Bug fix in singular location view that was preventing display of additional custom meta data when using the included location post type
- “Reset to Default” button added to post type settings for resetting to plugin defaults in cases of inadvertently changing critical post type settings.
- Conflict with nonce and page caching resolved
- German translation added (provided by Slava Klejman)
- Option added to hide default post type
- Added post id to search result data, added to marker click callback function and data attribute on view location link
- Bug fix in singular view
- A new shortcode [simple_locator_all_locations] is now available. The shortcode displays a map with all locations, zoomed to fit.
- Missing localized strings added for translations
- Option to add default empty map below search form on page load (visit Simple Locator settings to configure a default map)
- Option to enable default results – if user has geolocation enabled and permits access to your site, results will automatically load using their location
- Option added to limit results
- Admin UI Enhancements
- Portuguese translation (Luis Martens)
- Option added to remove Google Maps API script from output (to prevent conflicts with other plugins already outputting the script)
- Option added to include geolocation button in search form, with customizable button text
- Bug fixes in location fields when using a custom post type other than location. Option added to set menu icon for location/custom post type
- Options added to customize the included locations post type and its labels
- Minor Bug fixes in compatibility with other plugins
- Added option to select hidden meta fields for custom field selection
- Bug fix in singular post view map display
- Bug fix in custom post type meta field selection
- Localization bug fixes
- Initial release