If your plugin or website uses location data, you should be using WP-GeoMeta-Lib. WP-GeoMeta-Lib makes using spatial data easy and efficient.
WP-GeoMeta-Lib was created with developers in mind. If you find it cumbersome, buggy or missing features, let us know!
- Download WP-GeoMeta-Lib to your plugin.
git clone https://github.com/BrilliantPlugins/wp-geometa-lib
- Require
wp-geometa-lib-loader.php
in your plugin code.
require_once('wp-geometa-lib/wp-geometa-lib-loader.php');
- Set up an activation hook to install WP-GeoMeta-lib when your plugin activates.
register_activation_hook( __FILE__ , array('WP_GeoMeta','install'));
If you already have your own activation hook, you can simply add WP_GeoMeta::install() to your hook.
- Save GeoJSON metadata!
update_post_meta( 15, 'my_meta_key', '[{GeoJSON}](http://geojson.org)' );
Once you are storing spatial data you (or anyone else!) can query it using spatial queries!
This talk by Michael Moore and accompanying slides give an excellent overview of the project.
We believe that WP-GeoMeta-lib is the best and easiest way to work spatial data in WordPress. If an opinion alone isn't enough, see some of our reasons and decide on your own.
You'll need at least WordPress 6 and MySQL 5.7. More details here.
WP-GeoMeta-lib uses WordPress hooks to detect when spatial metadata is being stored, or when it's being queried. It then routes the spatial data, or the spatial part of the query to a set of tables that support spatial data.
Interested in contributing? Dive in to the code (it should be well documented) and check out HACKING.md.