开发者 | dshanske |
---|---|
更新时间 | 2024年2月3日 12:49 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 6.4 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
API Keys are required to use certain services.
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
:
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.
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.
The Development Version as well as support can be found on Github.
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:
en_us
.get_geodata
function now supports WP_Post, WP_Comment, and WP_Term objects