Skip to content

Commit

Permalink
v1.1 - Route GeoJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
morehawes committed Oct 12, 2022
1 parent d588e78 commit e5fde7b
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 21 deletions.
19 changes: 17 additions & 2 deletions build/App/Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public function handle_shortcode($shortcode_data, $content = null) {
'mapshare_identifier' => 'demo',
'mapshare_password' => false,
'mapshare_date_start' => false,
'mapshare_date_end' => false
'mapshare_date_end' => false,
'mapshare_route_url' => false
), $shortcode_data, Joe_v1_0_Config::get_item('plugin_shortcode'));

if($shortcode_data['mapshare_identifier']) {
Expand Down Expand Up @@ -147,12 +148,26 @@ public function handle_shortcode($shortcode_data, $content = null) {
$point_text = ($point_count == 1) ? __('Point', Joe_v1_0_Config::get_item('plugin_text_domain')) : __('Points', Joe_v1_0_Config::get_item('plugin_text_domain'));

Joe_v1_0_Log::add(sprintf(__('Displaying %s MapShare', Joe_v1_0_Config::get_item('plugin_text_domain')), $point_count) . ' ' . $point_text, 'success', 'rendering_points');

//Route?
$route_json = null;
$route_url = filter_var($shortcode_data['mapshare_route_url'], FILTER_VALIDATE_URL);
if($route_url && $route_json = file_get_contents($route_url)) {

//Valid
if(json_decode($route_json)) {
Joe_v1_0_Log::add(__('Displaying route JSON.', Joe_v1_0_Config::get_item('plugin_text_domain')), 'success', 'route_valid');
} else {
Joe_v1_0_Log::add(__('Invalid route JSON.', Joe_v1_0_Config::get_item('plugin_text_domain')), 'error', 'route_invalid');
}
}

//JS
Joe_v1_0_Assets::js_onready('
inmap_create_map(
"' . $hash . '",
' . $geojson . '
' . $geojson . ',
' . $route_json . '
);
');

Expand Down
26 changes: 23 additions & 3 deletions build/assets/js/shortcode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Leaflet
const inmap_maps = [];

const inmap_create_map = function(map_hash = null, map_geojson = null) {
const inmap_create_map = function(map_hash = null, map_geojson = null, route_json = null) {
if(! map_hash || ! map_geojson || ! jQuery || typeof inmap_L !== 'object') {
return false;
}
Expand Down Expand Up @@ -240,6 +240,21 @@ const inmap_create_map = function(map_hash = null, map_geojson = null) {
}
};

var display_geojson = function(geojson) {
//JSON layer
inmap_L.geoJSON(geojson, {
//Style
style: {
"color": "#ff7800",
"weight": 3,
"opacity": 0.5
},
onEachFeature: function(feature, layer) {
layer.bindTooltip('Planned Route');
}
}).addTo(map_l);
};

// Create Tile Layer

//Basemap
Expand Down Expand Up @@ -330,7 +345,7 @@ const inmap_create_map = function(map_hash = null, map_geojson = null) {
});
}
});

//Add
data_layer.addTo(map_l);

Expand All @@ -339,5 +354,10 @@ const inmap_create_map = function(map_hash = null, map_geojson = null) {
setup_ui();
});

map_l.fitBounds(data_layer.getBounds());
map_l.fitBounds(data_layer.getBounds());

//Route? (must be valid JSON)
if(route_json && JSON.stringify(route_json)) {
display_geojson(route_json);
}
};
2 changes: 1 addition & 1 deletion build/assets/js/shortcode.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/inreach-mapshare.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: inReach MapShare
Plugin URI: https://github.com/morehawes/inreach-mapshare
Description: Display inReach MapShare data on your WordPress site. Visit the <a href="options-general.php?page=inreach-mapshare-settings">Settings</a> page to create and customise Shortcodes.
Version: 1.0.2
Version: 1.1
Text Domain: inreach-mapshare
Author: Joe Hawes
Author URI: https://www.morehawes.co.uk/
Expand Down Expand Up @@ -50,7 +50,7 @@
'plugin_slug' => $plugin_slug,
'plugin_text_domain' => $plugin_slug,
'plugin_name' => $plugin_name,
'plugin_version' => '1.0.2',
'plugin_version' => '1.1',
'settings_id' => 'inmap_settings',
'settings_default_tab' => 'joe-settings-tab-mapshare',
'site_url' => 'https://github.com/morehawes/inreach-mapshare/',
Expand Down
24 changes: 16 additions & 8 deletions build/inreach-mapshare.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the same license as the inReach MapShare package.
msgid ""
msgstr ""
"Project-Id-Version: inReach MapShare 1.0.2\n"
"Project-Id-Version: inReach MapShare 1.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/build\n"
"POT-Creation-Date: 2022-10-12 12:18:17+00:00\n"
"POT-Creation-Date: 2022-10-12 12:33:01+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -82,11 +82,11 @@ msgid ""
"MapShare data will be displayed!</strong>"
msgstr ""

#: App/Inreach.php:209 App/Shortcode.php:147
#: App/Inreach.php:209 App/Shortcode.php:148
msgid "Point"
msgstr ""

#: App/Inreach.php:209 App/Shortcode.php:147
#: App/Inreach.php:209 App/Shortcode.php:148
msgid "Points"
msgstr ""

Expand Down Expand Up @@ -247,19 +247,27 @@ msgid ""
"href=\"%s\">protecting access</a> if needed."
msgstr ""

#: App/Shortcode.php:141
#: App/Shortcode.php:142
msgid "Rendering Map"
msgstr ""

#: App/Shortcode.php:149
#: App/Shortcode.php:150
msgid "Displaying %s MapShare"
msgstr ""

#: App/Shortcode.php:167
#: App/Shortcode.php:159
msgid "Displaying route JSON."
msgstr ""

#: App/Shortcode.php:161
msgid "Invalid route JSON."
msgstr ""

#: App/Shortcode.php:182
msgid "GeoJSON contains no Points."
msgstr ""

#: App/Shortcode.php:171
#: App/Shortcode.php:186
msgid "MapShare Identifier not provided."
msgstr ""

Expand Down
13 changes: 12 additions & 1 deletion build/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: inreach, mapshare, embed, map, share, location
Requires at least: 4.6
Tested up to: 6.0
Requires PHP: 7.4
Stable tag: 1.0.2
Stable tag: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,11 +24,18 @@ By default only your most recent location is displayed. To display more data, St
[inreach-mapshare mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00" mapshare_date_end="2022-07-31T23:59"]
`

You can display a GeoJSON Route accessible via a URL like this:

`
[inreach-mapshare mapshare_route_url="https://www.example.com/my-route.geojson" mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00"]
`

The MapShare feature must be enabled in the <a href="https://explore.garmin.com/Social">Social</a> tab of your Garmin Explore account.

Features:

* Embed an interactive Map and timeline containing track points and messages shared with your MapShare page.
* Display your planned route using the Shortcode (URL accessible GeoJSON supported).
* Each point displayed contains the following information:
* Time UTC
* Time (local)
Expand Down Expand Up @@ -93,6 +100,10 @@ This plugin requests data from your MapShare page and embeds it anywhere Shortco

== Changelog ==

= 1.1 =

Display your planned route using the Shortcode (URL accessible GeoJSON supported).

= 1.0.2 =

Settings improvements.
Expand Down
4 changes: 2 additions & 2 deletions inreach-mapshare.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: inReach MapShare
Plugin URI: https://github.com/morehawes/inreach-mapshare
Description: Display inReach MapShare data on your WordPress site. Visit the <a href="options-general.php?page=inreach-mapshare-settings">Settings</a> page to create and customise Shortcodes.
Version: 1.0.2
Version: 1.1
Text Domain: inreach-mapshare
Author: Joe Hawes
Author URI: https://www.morehawes.co.uk/
Expand Down Expand Up @@ -50,7 +50,7 @@
'plugin_slug' => $plugin_slug,
'plugin_text_domain' => $plugin_slug,
'plugin_name' => $plugin_name,
'plugin_version' => '1.0.2',
'plugin_version' => '1.1',
'settings_id' => 'inmap_settings',
'settings_default_tab' => 'joe-settings-tab-mapshare',
'site_url' => 'https://github.com/morehawes/inreach-mapshare/',
Expand Down
Binary file modified inreach-mapshare.zip
Binary file not shown.
13 changes: 12 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Requires at least:** 4.6
**Tested up to:** 6.0
**Requires PHP:** 7.4
**Stable tag:** 1.0.2
**Stable tag:** 1.1
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,11 +24,18 @@ By default only your most recent location is displayed. To display more data, St
[inreach-mapshare mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00" mapshare_date_end="2022-07-31T23:59"]


You can display a GeoJSON Route accessible via a URL like this:


[inreach-mapshare mapshare_route_url="https://www.example.com/my-route.geojson" mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00"]


The MapShare feature must be enabled in the <a href="https://explore.garmin.com/Social">Social</a> tab of your Garmin Explore account.

Features:

* Embed an interactive Map and timeline containing track points and messages shared with your MapShare page.
* Display your planned route using the Shortcode (URL accessible GeoJSON supported).
* Each point displayed contains the following information:
* Time UTC
* Time (local)
Expand Down Expand Up @@ -105,6 +112,10 @@ This plugin requests data from your MapShare page and embeds it anywhere Shortco

## Changelog ##

### 1.1 ###

Display your planned route using the Shortcode (URL accessible GeoJSON supported).

### 1.0.2 ###

Settings improvements.
Expand Down
13 changes: 12 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: inreach, mapshare, embed, map, share, location
Requires at least: 4.6
Tested up to: 6.0
Requires PHP: 7.4
Stable tag: 1.0.2
Stable tag: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,11 +24,18 @@ By default only your most recent location is displayed. To display more data, St
[inreach-mapshare mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00" mapshare_date_end="2022-07-31T23:59"]
`

You can display a GeoJSON Route accessible via a URL like this:

`
[inreach-mapshare mapshare_route_url="https://www.example.com/my-route.geojson" mapshare_identifier="your_identifier" mapshare_date_start="2022-06-15T00:00"]
`

The MapShare feature must be enabled in the <a href="https://explore.garmin.com/Social">Social</a> tab of your Garmin Explore account.

Features:

* Embed an interactive Map and timeline containing track points and messages shared with your MapShare page.
* Display your planned route using the Shortcode (URL accessible GeoJSON supported).
* Each point displayed contains the following information:
* Time UTC
* Time (local)
Expand Down Expand Up @@ -93,6 +100,10 @@ This plugin requests data from your MapShare page and embeds it anywhere Shortco

== Changelog ==

= 1.1 =

Display your planned route using the Shortcode (URL accessible GeoJSON supported).

= 1.0.2 =

Settings improvements.
Expand Down

0 comments on commit e5fde7b

Please sign in to comment.