Adds geographic location and weather support to WordPress.
Supports adding geo coordinates, a location taxonomy, and a textual location description to a post, comment, user, or attachment. Supports adding weather data to a post or to a widget based on location.
Offers choice of map displays. It supports retrieving location using the HTML5 geolocation API by default. Clicking the location icon or ‘Lookup Location’ will retrieve the location.
As it stores the GeoData in the classic WordPress format, Geodata can also be added from other plugins.
Automatically saves location data from image metadata when uploaded as well.
Offers the opportunity to change the displayed timezone on a per-post basis for those posts from far off locations and set this based on the coordinates of the location.
While Gutenberg compatible, this is not built for Gutenberg.
Simple Location stores location and weather data inside posts, attachments, comments, and term meta…optionally other post types. This data respects a public, private or
protected setting. Attachment data is automatically extracted from images if location is present, which could be extracted by any third-party downloading the picture
unless removed. For all other data, it is provided by the user, who decides its ultimate use. Location data is made available through a geolocation provider…the default is currently
HTML5 browser geolocation, for which the user must give consent to share). Other information is secured through use of third-party APIs to identify a
location, calculate elevation, display maps, and weather conditions.
Locations uses WordPress taxonomies to allow you to generate an archive page of all posts from that location and giving it a permalink on your site. Locations are meant to reflect a more general
location…for example, “Here are posts I made in California.”
Locations are divided by administrative areas. The hierarchy for locations is:
* Country
* Region – state, county, or province level.
* Locality – city, town, or village level
You can choose to display the location over the textual address field. There is an option in settings to change this behavior.
The reverse geocoding system attempts to consistently retrieve the country code, region code, and locality for the location and add them to the location taxonomy. This can be potentially problematic, as if the returns
from the locations added aren’t consistent, it will duplicate and explode the list of terms. This is the same issue that has held back venues.
Locations are matched using the country code, region code, and locality field, and therefore, you can edit the displayed name or the region code without issue. Due to matching issues, you may have to make some manual changes and there may be some occasional duplication.
There is no top level Location page, /location included in the plugin. You can create a page at this location and use a custom template to allow it to show a list of your locations.
Venues are meant to reflect a specific location, such as a business or point of interest. Venues were originally set up as a taxonomy, and were in the plugin unimplemented for several versions. However,
due to various changes since that was set up, they were switched to a custom post type. Under this setup, each venue is represented by a URL on the site that posts can be linked to. The URL contains
information about the venue.
Zones allow for geofencing. You can set coordinates and a radius around them. If you set location to a place within a zone, the default behavior is to replace the location
with a preset Name and hide the coordinates. This allows you to protect private locations such as your home, or your place of business. For Micropub, it will set the location
as protected if the location is in the zone and the location-visibility property is not set. For the post editor in WordPress, looking up the location of an item inside the
zone will result in the visibility being set to protected and the name being set to the zone name. This can be overridden.
Zones are replaced as of 5.0.0 with Private Venues
Weather consists of at minimum the current conditions and temperature but includes future parameters for use such as pressure, wind speed, wind direction degree, etc. Weather widgets are available
that can be set to a specific location, a user, station ID, or airport code. Station ID is available from supported providers for weather stations, for example from a Personal Weather Station(PWS).
Stations allow for using a custom data source for weather data. This source should be a URL that returns a JSON object. When using the Custom Station provider for weather, it
will look for when one of the stations defined is within 10km of your current location. It will then use the return as the current weather conditions. Please note that the
return must be in the format documented in the code.
WordPress Geodata is an existing standardized way to store geodata about a post, user, comment, or term.
It consists of four fields: latitude, longitude, public, and address. This matches up with the HTML5 Geolocation fields. The W3C Geolocation Specification
also provides for properties of altitude, accuracy, altitudeAccuracy, speed, and heading, which may be stored. Map Zoom is also stored as a geodata property.
Timezone is also stored as a property and is derived from the location by default or set manually.
In order to access private location information, the following custom capabilities are added to WordPress:
* ‘read_{$object_type}location’ – Whether or not a user is allowed to read information locations for object types: posts, comments, terms, users. A user is always allowed to read the location from their objects.
* ‘edit{$object_type}_location’ – Whether or not a user is allowed to edit information locations for object types: posts, comments, terms, users. A user is always allowed to read the location from their objects.
The plugin is designed to be extensible and anyone could write a plugin that would add additional providers.
API Keys are required to use certain services.
* Google
* Mapbox – To retrieve style list inside the UI, you need a token with the styles:list scope
* Bing
* OpenWeatherMap
* MapQuest
* HERE
* Compass
* Weatherstack
* Weatherbit
* GeoNames – requires a username
* LocationIQ
* Met Office UK
* OpenRoute Service
* GeoApify
* Visual Crossing
* Meteostat
* Pirate Weather
* TomTom
* AerisWeather – Individuals who share their personal weather station data with PWSWeather.com are offered a free contributor account.
At this time, all map services require an API key, but most permit limited non-commercial use.
Nominatim does not require an API key, but it does ask for an email address, which will be the admin email of the site
If not provided there will be no map displayed regardless of setting, reverse geo lookup will not work
Without a weather provider this service will not work.
API Keys may have free limits, or may incur fees if overused. This plugin only uses a request when you post, which is usually well within the free tier which is usually thousands of requests. In all cases, you must comply
with the provider’s terms of use.
The appropriate API keys should be entered in Settings->Simple Location or will move to Indieweb->Location if the Indieweb plugin if installed.
add_post_type_support( ‘geo-location’);
add_post_type_support( ‘weather’ );
The software uses two custom features to declare that the post type supports these features, otherwise the location and weather features do not show in the editor.
The terms of service of most map providers expressly forbid this. While the likelihood of one of these providers coming after an individual is slim, this would be a violation of WordPress plugin guidelines.
This is why the plugin does not save maps to the media library. The only self-serve option being offered at this time is to self-host a caching static map API endpoint.
The custom map provider is an endpoint you provide yourself. You can install and use the repository here, which is a fork of a project by Aaron Parecki.
The custom provider was designed around the parameters in this code. All the commercial static map APIs used assemble the pieces of a map from public tile servers, which
is what this code does. While the code allows for multiple tile sources, please ensure compliance with their licenses. At the least, most of them require attribution.
This allows you to use a custom endpoint that returns current weather conditions in json, using the property names used by this plugin, which can be found outlined in the class-weather-provider.php file. The configuration for this
takes a URL and an ID. So you could run a script that generates a static page anywhere from any source with this data.
Currently, only Visual Crossing supports historic weather data on their basic plan. Meteostat consists solely of historical data and has no current data.
Several providers, including the custom provider, the National Weather Service(US), and the Met Office(UK) only provide limited locations for retrieving weather data. This specifies where to look if the first provider fails.
This may be replaced with better logic in future.
Simple Location uses WordPress Geodata to store location, as does the WordPress app. So setting location with the app should allow it to be displayed by Simple Location. The only major difference
is that whether or not a location is public is set with either 0 for private or 1 for public. The spec implemented states a non-zero number is considered public. This plugin adds the option of 2,
also known as protected, which shows a textual description of the location but does not display a map or geographic coordinates.
However, now that the WordPress apps no longer support location, this may be moot.
Chrome Users: Retrieves the location using the HTML5 geolocation API(available in your browser) will not work on Chrome if your website is not secure(https). This is a Chrome decision to ensure safe control of personal data.
You can take advantage of the other built-in location providers, for example, one uses the location of the user or create your own location provider as a separate plugin.
You can do so under your user profile or alternatively update using a REST API endpoint. By posting to /wp-json/sloc_geo/1.0/user
with the latitude, longitude, altitude parameters, or with a geojson body, will
update the user associated with the credentials you provide to the REST API.
There are REST API endpoints to retrieve the data so it can be used in the admin under the namespace /wp-json/sloc_geo/1.0
:
* /timezone which will return timezone data for a latitude/longitude or airport code
* /weather which will return the weather for a latitude/longitude or station ID
* /geocode which will return the address information for a latitude/longitude and optionally add the weather
* /lookup which will return the current location for a user based on the location provider
* /airport allows search for an airport by IATA code, ICAO code, or Municipality. Used for the airport location search
* /map which will return static map data for the provided latitude and longitude
Compass is a GPS tracking server that stores data in flat files. The instructions for installation are available in the GitHub repository. GPS
data can be sent to it from iOS or Android devices using various apps.
You can filter any query or archive by adding ?geo={all|public|text}
to it to show only public posts with location. Adding /geo/all to the homepage or archive pages should also work
If you add /map to any archive URL, for example, example.com/2019/map it will return a template with a map view of that archive. It uses a default template built into the theme.
Being as styling this would not be customized to your theme, you can add a map-archive.php file to your theme to customize this. For taxonomies, use /map/taxonomy/term.
JetPack only began offering location display in 2017, 3 years after this plugin was created. This plugin disables their implementation as it created conflicts.
They do not offer the features this plugin does and their goal is a minimal implementation.
en_us
.get_geodata
function now supports WP_Post, WP_Comment, and WP_Term objects