Updated event_osm to v0.3.7 (#124)
* default path for *.gpx files * path description fixed for many paths * escape map parameter * set default category id to "without" * removed not needed "global $serendipity;" * added README.md * updated event_osm to v0.3.7 Co-authored-by: surrim <surrim@happyhydro.org>
This commit is contained in:
parent
eff22e3f60
commit
8d8e6a1494
|
@ -1,3 +1,12 @@
|
||||||
|
0.3.7:
|
||||||
|
---
|
||||||
|
|
||||||
|
* Added README.md
|
||||||
|
* Set default category id to "without"
|
||||||
|
* Escape map parameter
|
||||||
|
* Path description fixed for many paths
|
||||||
|
* Default path for *.gpx files
|
||||||
|
|
||||||
0.3.6:
|
0.3.6:
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
121
serendipity_event_osm/README.md
Normal file
121
serendipity_event_osm/README.md
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
# OpenStreetMap plugin for Serendipity
|
||||||
|
|
||||||
|
With this plugin you can implement one ore more interactive
|
||||||
|
maps for geo tagged entries and uploaded \*.gpx files.
|
||||||
|
The map is build by [OpenLayers][ol], a high-performance
|
||||||
|
JavaScript library.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Some plugins are needed to make it work.
|
||||||
|
|
||||||
|
### serendipity_event_geo_json or Geo-JSON object
|
||||||
|
|
||||||
|
First you need a JSON object with all the geo information
|
||||||
|
for your maps. This can be simple done with the plugin
|
||||||
|
`serendipity_event_geo_json` or by hand as a JavaScript
|
||||||
|
global constant like below.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const geo = {
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"title": "I love Bochum",
|
||||||
|
"url": "/archives/12-I-love-Bochum.html",
|
||||||
|
"date": 1536588060,
|
||||||
|
"size": 211,
|
||||||
|
"author": "surrim",
|
||||||
|
"pos": [51.414369, 6.729898],
|
||||||
|
"categories": [42]
|
||||||
|
},
|
||||||
|
/* (more entries) */
|
||||||
|
],
|
||||||
|
"uploads": [
|
||||||
|
{
|
||||||
|
"title": "2021-06-30-essen-bochum.gpx",
|
||||||
|
"url": "/uploads/my-tour/2021-06-30-essen-bochum.gpx",
|
||||||
|
"date": 1610319360,
|
||||||
|
"size": 105144
|
||||||
|
},
|
||||||
|
/* (more uploads) */
|
||||||
|
]
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### serendipity_event_static_osm
|
||||||
|
|
||||||
|
Next you need `serendipity_event_static_osm`.
|
||||||
|
It's needed to include all OpenLayers scripts and
|
||||||
|
stylesheets once. It can also remove all unnecessary things
|
||||||
|
from \*.gpx files like timestamps and metadata. This
|
||||||
|
behavior is enabled by default.
|
||||||
|
Enabling this is highly recommented to minimize traffic and
|
||||||
|
for uploading tracked data, for example from OsmAnd or
|
||||||
|
Garmin.
|
||||||
|
Geo data (including altitudes) will be untouched.
|
||||||
|
|
||||||
|
### serendipity_event_osm
|
||||||
|
|
||||||
|
This plugin can be used to include map instances. You can
|
||||||
|
set a default map position, zoomlevel, one or
|
||||||
|
more folders for the \*.gpx files and categories.
|
||||||
|
It inserts a div-element like below.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div
|
||||||
|
class="map"
|
||||||
|
data-category="42"
|
||||||
|
data-path="/uploads/my-tour/"
|
||||||
|
data-latitude="45.76697"
|
||||||
|
data-longitude="4.83519"
|
||||||
|
data-zoom="4"
|
||||||
|
style="height: 463px"
|
||||||
|
></div>
|
||||||
|
```
|
||||||
|
|
||||||
|
All the div-elements will be processed by the mentioned
|
||||||
|
static scripts later.
|
||||||
|
You can display the total distance of all \*.gpx files by
|
||||||
|
using a span-element like this.
|
||||||
|
|
||||||
|
```html
|
||||||
|
Total distance: <span class="distance-counter" data-category="42">(calculating...)</span> kilometers.
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
Now you can enable the `serendipity_event_geotag` plugin to
|
||||||
|
enter coordinates of your entries. When you paste data like
|
||||||
|
"45.76697, 4.83519" it will be put into the latitude and
|
||||||
|
longitude fields. After saving the changes the entry will be
|
||||||
|
shown on the map.
|
||||||
|
Uploading \*.gpx files is even simpler. After uploading a
|
||||||
|
file you will find it on the map.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Minimap
|
||||||
|
For faster position changes
|
||||||
|
- Fullscreen mode
|
||||||
|
To use all of the pixels of your monitor or smartphone
|
||||||
|
display
|
||||||
|
- Zoom
|
||||||
|
You can use the mouse wheel, double click, use the buttons
|
||||||
|
or two fingers on touchscreens to zoom
|
||||||
|
- Scale
|
||||||
|
Shown to make it easier to see distances
|
||||||
|
- Rainbow colors
|
||||||
|
The date of the entries and \*.gpx files is used to
|
||||||
|
calculate its color by the day of the month. For example
|
||||||
|
dates at the beginning or end of a month are red, dates in
|
||||||
|
the middle of a months are cyan
|
||||||
|
- Interaction
|
||||||
|
When you click on the map it will display a list of
|
||||||
|
entries to read and tracks to download. Extra information
|
||||||
|
like track length and date is shown as a tooltip
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
Martin Sewelies <ruhrtour@surrim.org>
|
||||||
|
|
||||||
|
[ol]: https://openlayers.org/
|
|
@ -11,7 +11,7 @@
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
|
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad für GPX-Dateien');
|
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
|
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
|
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
|
||||||
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
|
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Ohne');
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Beliebig');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
|
@define('PLUGIN_EVENT_OSM_PATH', 'Pfad');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad für GPX-Dateien');
|
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Pfad(e) für GPX-Dateien, getrennt durch Zeilenumbruch');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
|
@define('PLUGIN_EVENT_OSM_LAT', 'Breitengrad (Lat.)');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
|
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Breitengrad für die Mitte der Karte');
|
||||||
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
|
@define('PLUGIN_EVENT_OSM_LONG', 'Längengrad (Lon.)');
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Without');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_WITHOUT', 'Without');
|
||||||
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Any');
|
@define('PLUGIN_EVENT_OSM_CATEGORY_ANY', 'Any');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH', 'Path');
|
@define('PLUGIN_EVENT_OSM_PATH', 'Path');
|
||||||
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path for GPX-files');
|
@define('PLUGIN_EVENT_OSM_PATH_DESCRIPTION', 'Path(s) for GPX-files, separated by linebreak');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
|
@define('PLUGIN_EVENT_OSM_LAT', 'Latitude');
|
||||||
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Latitude of the center of the map');
|
@define('PLUGIN_EVENT_OSM_LAT_DESCRIPTION', 'Latitude of the center of the map');
|
||||||
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
|
@define('PLUGIN_EVENT_OSM_LONG', 'Longitude');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.6');
|
@define('PLUGIN_EVENT_OSM_VERSION', '0.3.7');
|
||||||
@define('PLUGIN_EVENT_OSM_AUTHOR', 'Martin Sewelies');
|
@define('PLUGIN_EVENT_OSM_AUTHOR', 'Martin Sewelies');
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -65,7 +65,13 @@
|
||||||
||
|
||
|
||||||
in_array($category_id, $page_categories)
|
in_array($category_id, $page_categories)
|
||||||
) {
|
) {
|
||||||
echo ' <div class="map" data-category="'.$category_id.'" data-path="'.$this->get_config('path', '').'" data-latitude="'.$this->get_config('latitude', 51.48165).'" data-longitude="'.$this->get_config('longitude', 7.21648).'" data-zoom="'.$this->get_config('zoom', 15).'" style="height: '.$this->get_config('height', '463px').'"></div>'.PHP_EOL;
|
echo ' <div class="map" data-category="' . $category_id
|
||||||
|
. '" data-path="' . addslashes($this->get_config('path', ''))
|
||||||
|
. '" data-latitude="' . ((float)$this->get_config('latitude', 51.48165))
|
||||||
|
. '" data-longitude="' . ((float)$this->get_config('longitude', 7.21648))
|
||||||
|
. '" data-zoom="' . ((int)$this->get_config('zoom', 15))
|
||||||
|
. '" style="height: ' . addslashes($this->get_config('height', '463px'))
|
||||||
|
. '"></div>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +91,7 @@
|
||||||
|
|
||||||
function introspect_config_item($name, &$propbag)
|
function introspect_config_item($name, &$propbag)
|
||||||
{
|
{
|
||||||
|
global $serendipity;
|
||||||
switch($name) {
|
switch($name) {
|
||||||
case 'title':
|
case 'title':
|
||||||
$propbag->add('type', 'string');
|
$propbag->add('type', 'string');
|
||||||
|
@ -97,13 +104,13 @@
|
||||||
$propbag->add('name', PLUGIN_EVENT_OSM_CATEGORY);
|
$propbag->add('name', PLUGIN_EVENT_OSM_CATEGORY);
|
||||||
$propbag->add('description', PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION);
|
$propbag->add('description', PLUGIN_EVENT_OSM_CATEGORY_DESCRIPTION);
|
||||||
$propbag->add('select_values', $this->get_selectable_categories());
|
$propbag->add('select_values', $this->get_selectable_categories());
|
||||||
$propbag->add('default', 'all');
|
$propbag->add('default', 'without');
|
||||||
break;
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
$propbag->add('type', 'text');
|
$propbag->add('type', 'text');
|
||||||
$propbag->add('name', PLUGIN_EVENT_OSM_PATH);
|
$propbag->add('name', PLUGIN_EVENT_OSM_PATH);
|
||||||
$propbag->add('description', PLUGIN_EVENT_OSM_PATH_DESCRIPTION);
|
$propbag->add('description', PLUGIN_EVENT_OSM_PATH_DESCRIPTION);
|
||||||
$propbag->add('default', '');
|
$propbag->add('default', $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath']);
|
||||||
break;
|
break;
|
||||||
case 'height':
|
case 'height':
|
||||||
$propbag->add('type', 'string');
|
$propbag->add('type', 'string');
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
function event_hook($event, &$bag, &$eventData, $addData = null)
|
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||||
{
|
{
|
||||||
global $serendipity;
|
|
||||||
if ($event === 'frontend_header') {
|
if ($event === 'frontend_header') {
|
||||||
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/ol.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
|
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/ol.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
|
||||||
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/osm.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
|
echo ' <link rel="stylesheet" href="'.$this->getFile('ressources/osm.css', 'serendipityHTTPPath').'" type="text/css" />'.PHP_EOL;
|
||||||
|
|
Loading…
Reference in a new issue