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 [wp_simple_locator]. There are several options available for customizing the form and results:
- distances – A comma separated list of numbers used to ustomize the list of available distances to choose from in the form
- mapheight – The height of the map in pixels
- mapcontainer – The unique ID of a custom container in which to load the map.
- resultscontainer – The unique ID of a custom container in which to load the search results.
- buttontext – Text to display in submit button
- addresslabel – Customize the address form label
- mapcontrols – Hide or show the map controls
- mapcontrolsposition – Google Maps formatted position for map controls (ex: TOP_LEFT)
- placeholder – Customize the search input placeholder text (added in v1.3.0)
- noresultstext – Customize the text displayed if no results are returned (added in v1.3.0)
- 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. (added in v1.3.0)
- 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)
- allowemptyaddress – Set as “true” to allow empty address fields to be submitted (useful for returning all locations regardless of the user-specified location)
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
- 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?
Col·laboradors i desenvolupadors
«Simple Locator» és programari de codi obert. La següent gent ha col·laborat en aquesta extensió.Col·laboradors
Registre de canvis
- Security Update
- 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
- Versió inicial