dshanske / simple-location

Adds Basic Location Support to Wordpress
https://wordpress.org/plugins/simple-location
Other
28 stars 14 forks source link
geodata geolocation html5-geolocation-api location timezone weather wordpress

Simple Location

Contributors: dshanske
Tags: geolocation, timezones, geo, maps, location, weather, indieweb
Requires at least: 4.9
Tested up to: 6.4
Stable tag: 5.0.23
Requires PHP: 5.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Adds geographic location and weather support to WordPress.

Description

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.

Privacy and Data Notice

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 and Venues

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:

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

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

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

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

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:

Providers

The plugin is designed to be extensible and anyone could write a plugin that would add additional providers.

Frequently Asked Questions

What are the requirements to use this plugin?

API Keys are required to use certain services.

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.

How do I add support for location to a custom post type?

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.

Why are my maps served from the provider instead of saved as images to my site?

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.

What is the custom map provider?

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.

What is the custom weather provider?

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.

Which providers support historic weather data?

Currently, only Visual Crossing supports historic weather data on their basic plan. Meteostat consists solely of historical data and has no current data.

What is the fallback weather provider?

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.

Is this compatible with the WordPress mobile apps?

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.

The Location Icon does not retrieve my location.

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.

How can I update the location of my user profile?

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.

How can I access the location or weather data on the frontend?

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:

What is Compass?

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.

How can I show a list of posts tagged with a location?

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

How can I see a map of all the locations in an archive page?

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 offers Location Display, why do I need this?

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.

Why am I seeing location on private posts with the notation Hidden?

This appears to users who can read private posts when logged in. It does not appear when not logged in. The same applies to the location taxonomy. If you are not logged in, or are logged in and don't have the read_private_posts permission, you won't see posts with private locations.

How can I report issues or request support?

The Development Version as well as support can be found on Github.

How can I add support for ___ ?

Simple Location has the concept of Providers. Providers are an abstract class that you can implement to take information from one format into the one Simple Location understands. The plugin offers providers for:

What icons are used here?

Upgrade Notice

5.0.0

Due to extensive refactoring in this version, there may be unanticipated behavior. Old functions have been removed and users calling them directly may need to New global functions have been introduced to reduce the calls to specific classes. Weather and location data has been separated into separate storage locations and functions, with a new signature based on the Metadata API. This means that rolling back once the data is migrated could be problematic and the recommendation is to backup before upgrading.

Venues are introduced officially. They replace the Zone feature and will be expanded to additional functionality in future. They should be considered a beta feature at this point.

The ability to set location taxonomy to display over address is currently global. Will be looking for better control in future.

4.4.0

This update includes support for Locations. Which will be generated when a new location is looked up.

4.1.5

Wikimedia Maps has turned off third-party access and advised they have no plans to return it. So this service is now removed. Added some new services to cover.

4.1.0

Dark Sky has been acquired by Apple and no longer permits you to apply for an API key. If you already have one, the functionality in this plugin will work, according to them, until end of 2021 after which it will be removed from this plugin. The plugin offers several other weather providers. The Met Office weather plugin has not been tested in live use as the developer is not in the UK. It is also not as detailed as some of the other options in what data it provides.

4.0.0

The Compass API/URL information is now stored in the user profile. When publishing, it will pull this information in from the current logged in user. This was previously stored globally. When using UTC offsets over timezone strings, only systems running PHP5.5 and above will work correctly. Default height for maps has been replaced by aspect ratio.

3.7.0

This upgrade cleans up some possibly old data in the database when you load the settings page for the plugin. If you have a lot of posts, the load may be slow initially.

3.4.0

Hardcoded and filtered options for new providers have been replaced by a provider registration function with the strings and slug for the provider set inside the provider itself.

3.0.0

Recommend backup before upgrade to Version 3.0.0 due to the start of venue support. Full location data will not be saved in the post and old posts will be converted. The display name will be saved if set, otherwise a display name will be set from the coordinates. An API key will now be required to show maps for services that require API keys.

Changelog

5.0.23 ( 2024-02-02 )

5.0.22 ( 2023-12-25 )

5.0.21 ( 2023-12-23 )

5.0.20 ( 2023-12-17 )

5.0.19 ( 2023-12-12 )

5.0.18 ( 2023-11-11 )

5.0.17 ( 2023-10-02 )

5.0.16 ( 2023-07-15 )

5.0.15 ( 2023-07-01 )

5.0.14 ( 2023-06-03 )

5.0.13 ( 2023-05-02 )

5.0.12 ( 2023-04-30 )

5.0.11 ( 2023-04-14 )

5.0.10 (2023-03-13 )

5.0.9 ( 2023-03-12 )

5.0.8 ( 2023-03-08 )

5.0.7 ( 2023-01-10 )

5.0.6 ( 2023-01-02 )

5.0.5 ( 2022-12-27 )

5.0.4 ( 2022-11-25 )

5.0.3 ( 2022-11-13 )

5.0.2 ( 2022-11-12 )

5.0.1 ( 2022-11-06 )

5.0.0 ( 2022-11-05 )

4.5.0 ( 2022-06-17 )

4.4.15 ( 2022-01-26 )

4.4.14 ( 2021-11-12 )

4.4.13 ( 2021-11-02 )

4.4.12 ( 2021-10-30 )

4.4.11 ( 2021-09-28 )

4.4.10 ( 2021-09-06 )

4.4.9 ( 2021-08-21 )

4.4.8 ( 2021-07-23 )

4.4.7 ( 2021-05-14 )

4.4.6 ( 2021-04-05 )

4.4.5 ( 2021-02-27 )

4.4.4 ( 2021-02-27 )

4.4.3 ( 2021-02-13 )

4.4.2 ( 2021-02-09 )

4.4.1 ( 2021-02-07 )

4.4.0 ( 2021-02-07 )

4.3.0 ( 2021-01-09 )

4.2.3 ( 2021-01-03 )

4.2.2 ( 2021-01-02 )

4.2.1 ( 2020-12-10 )

4.2.0 ( 2020-11-24 )

4.1.12 ( 2020-11-01 )

4.1.11 ( 2020-10-16 )

4.1.10 ( 2020-10-11 )

4.1.9 ( 2020-08-15 )

4.1.8 ( 2020-07-12 )

4.1.7 ( 2020-07-12 )

4.1.6 ( 2020-07-12 )

4.1.5 ( 2020-07-04 )

4.1.4 ( 2020-06-28 )

4.1.3 ( 2020-06-24 )

4.1.2 ( 2020-06-12 )

4.1.1 ( 2020-05-27 )

4.0.6 ( 2020-04-12 )

4.0.5 ( 2020-03-18 )

4.0.4 ( 2020-02-17 )

4.0.3 ( 2020-01-26 )

4.0.2 ( 2019-12-22 )

4.0.1 ( 2019-11-24 )

4.0.0 ( 2019-11-18 )

3.8.2 ( 2019-09-21 )

3.8.1 ( 2019-06-16 )

3.8.0 ( 2019-05-26 )

3.7.2 ( 2019-05-17 )

3.7.1 ( 2019-05-12 )

3.7.0 ( 2019-04-13 )

3.6.4 ( 2019-04-01 )

3.6.3 ( 2019-03-31 )

3.6.2 ( 2019-02-25 )

3.6.1 ( 2019-02-23 )

3.6.0 ( 2019-02-23 )

3.5.3 ( 2019-01-04 )

3.5.2 ( 2018-12-22 )

3.5.1 ( 2018-12-19 )

3.5.0 ( 2018-12-19 )

3.4.1 ( 2018-11-02 )

3.4.0 ( 2018-10-27 )

3.3.8 ( 2018-05-27 )

3.3.7 ( 2018-05-14 )

3.3.6 ( 2018-05-12 )

3.3.5 ( 2018-04-15 )

3.3.4 ( 2018-03-27 )

3.3.3 ( 2018-03-26 )

3.3.2 ( 2018-02-03 )