From c87496127f02951c6a11a39a483376213f999c40 Mon Sep 17 00:00:00 2001 From: bastianonm Date: Mon, 27 Feb 2017 08:47:04 +0000 Subject: [PATCH] * Added google maps api key on settings * Removed parameter 'sensor' on google maps js * Added unit of measure of speed for swimmers: min/100 meters --- WP-GPX-Maps.js | 18 ++++---- readme.txt | 7 +++- wp-gpx-maps.php | 76 +++++++++++++--------------------- wp-gpx-maps_admin.php | 2 +- wp-gpx-maps_admin_settings.php | 14 +++---- 5 files changed, 51 insertions(+), 66 deletions(-) diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js index 280c883..e0a1c73 100644 --- a/WP-GPX-Maps.js +++ b/WP-GPX-Maps.js @@ -937,26 +937,28 @@ Author URI: http://www.pedemontanadelgrappa.it/ l_y_arr.push(l_y); } - if (graphSpeed != '') - { - - if (unitspeed == '5') // knots + if (graphSpeed != '') { + if (unitspeed == '6') /* min/100m */ + { + l_s = { suf : "min/100m", dec : 2 }; + } + else if (unitspeed == '5') /* knots */ { l_s = { suf : "knots", dec : 2 }; } - else if (unitspeed == '4') // min/miles + else if (unitspeed == '4') /* min/miles */ { l_s = { suf : "min/mi", dec : 2 }; } - else if (unitspeed == '3') // min/km + else if (unitspeed == '3') /* min/km */ { l_s = { suf : "min/km", dec : 2 }; } - else if (unitspeed == '2') // miles/h + else if (unitspeed == '2') /* miles/h */ { l_s = { suf : "mi/h", dec : 0 }; } - else if (unitspeed == '1') // km/h + else if (unitspeed == '1') /* km/h */ { l_s = { suf : "km/h", dec : 0 }; } diff --git a/readme.txt b/readme.txt index 393dbfb..159ee2a 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: maps, gpx, gps, graph, chart, google maps, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Requires at least: 2.0.0 Tested up to: 4.6.1 -Stable tag: 1.3.12 +Stable tag: 1.3.13 Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. @@ -153,7 +153,10 @@ Yes! 1. Altitude & Speed 1. Altitude & Speed & Hearth rate -== Changelog == +== Changelog === 1.3.13 = +* Added google maps api key on settings +* Removed parameter 'sensor' on google maps js +* Added unit of measure of speed for swimmers: min/100 meters = 1.3.12 = * Fix incompatibility with Debian PHP7 (thanks to phbaer) https://github.com/devfarm-it/wp-gpx-maps/pull/5 = 1.3.10 = diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index ae5ed9c..9e1c6d2 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -3,7 +3,7 @@ Plugin Name: WP-GPX-Maps Plugin URI: http://www.devfarm.it/ Description: Draws a GPX track with altitude chart -Version: 1.3.12 +Version: 1.3.13 Author: Bastianon Massimo Author URI: http://www.pedemontanadelgrappa.it/ */ @@ -47,11 +47,11 @@ function WP_GPX_Maps_action_links($links, $file) { } function enqueue_WP_GPX_Maps_scripts() -{ - wp_enqueue_script( 'jquery' ); - wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?sensor=false', null, null); +{ $wpgpxmaps_googlemapsv3_apikey = get_option('wpgpxmaps_googlemapsv3_apikey'); + wp_enqueue_script( 'jquery' ); if ($wpgpxmaps_googlemapsv3_apikey) { wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?key='.$wpgpxmaps_googlemapsv3_apikey, null, null); } else { wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js', null, null); } + wp_enqueue_script( 'highcharts', "//code.highcharts.com/3.0.10/highcharts.js", array('jquery'), "3.0.10", true); - wp_enqueue_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.3.8"); + wp_enqueue_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.3.13"); } function print_WP_GPX_Maps_styles() @@ -265,7 +265,6 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') } else { $mtime = 0; } - $cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9"; $cacheFileName = md5($cacheFileName); @@ -734,10 +733,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') return $output; } -function convertSeconds($s) -{ - if ($s ==0) - return 0; +function convertSeconds($s){ + if ($s ==0) return 0; $s = 1.0 / $s; $_sSecT = $s * 60; //sec/km $_sMin = floor ( $_sSecT / 60 ); @@ -745,50 +742,35 @@ function convertSeconds($s) return $_sMin + $_sSec / 100; } -function convertSpeed($speed,$uomspeed, $addUom = false) -{ - +function convertSpeed($speed,$uomspeed, $addUom = false){ $uom = ''; - - if ($uomspeed == '5') // knots - { - $speed *= 1.94384449; + if ($uomspeed == '6') /* min/100 meters */ + { + $speed = 1 / $speed * 100 / 60 ; + $uom = " min/100m"; + } else if ($uomspeed == '5') /* knots */ { + $speed *= 1.94384449; $uom = " knots"; - } - else if ($uomspeed == '4') // min/mi - { - $speed = convertSeconds($speed * 0.037282272); + } else if ($uomspeed == '4') /* min/mi */ { + $speed = convertSeconds($speed * 0.037282272); $uom = " min/mi"; - } - else if ($uomspeed == '3') // min/km - { - $speed = convertSeconds($speed * 0.06); + } else if ($uomspeed == '3') /* min/km */ { + $speed = convertSeconds($speed * 0.06); $uom = " min/km"; - } - else if ($uomspeed == '2') // miles/h - { - $speed *= 2.2369362920544025; + } else if ($uomspeed == '2') /* miles/h */ { + $speed *= 2.2369362920544025; $uom = " mi/h"; - } - else if ($uomspeed == '1') // km/h - { - $speed *= 3.6; + } else if ($uomspeed == '1') /* km/h */ { + $speed *= 3.6; $uom = " km/h"; + } else /* dafault m/s */ { + $uom = " m/s"; + } + if ($addUom == true) { + return number_format ( $speed , 2 , '.' , '' ) . $uom; + } else { + return number_format ( $speed , 2 , '.' , '' ); } - else // dafault m/s - { - $uom = " m/s"; - } - - if ($addUom == true) - { - return number_format ( $speed , 2 , '.' , '' ) . $uom; - } - else - { - return number_format ( $speed , 2 , '.' , '' ); - } - } function downloadRemoteFile($remoteFile) diff --git a/wp-gpx-maps_admin.php b/wp-gpx-maps_admin.php index df2caf4..b9b1f17 100644 --- a/wp-gpx-maps_admin.php +++ b/wp-gpx-maps_admin.php @@ -121,7 +121,7 @@ function WP_GPX_Maps_html_page() {
  • glinecolorhr: heart rate line color (default is #ff77bd)
  • glinecolorcad: cadence line color (default is #beecff)
  • glinecolorgrade: grade line color (default is #beecff) -
  • uomspeed: unit of measure for speed are: 0, 1, 2, 3, 4, 5 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots)) +
  • uomspeed: unit of measure for speed are: 0, 1, 2, 3, 4, 5 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters)
  • chartFrom1: minimun value for altitude chart
  • chartTo1: maxumin value for altitude chart
  • chartFrom2: minimun value for speed chart diff --git a/wp-gpx-maps_admin_settings.php b/wp-gpx-maps_admin_settings.php index 09f48f9..420095e 100644 --- a/wp-gpx-maps_admin_settings.php +++ b/wp-gpx-maps_admin_settings.php @@ -35,9 +35,8 @@ $avg_speed = get_option("wpgpxmaps_summary_avg_speed"); $total_time = get_option("wpgpxmaps_summary_total_time"); - $usegpsposition = get_option("wpgpxmaps_usegpsposition"); - - $distanceType = get_option("wpgpxmaps_distance_type"); + $usegpsposition = get_option("wpgpxmaps_usegpsposition"); + $distanceType = get_option("wpgpxmaps_distance_type"); $distanceType = get_option("wpgpxmaps_googlemapsv3_apikey"); if (empty($showEle)) $showEle = "true"; @@ -84,7 +83,7 @@ - + Cache: @@ -103,12 +102,11 @@ onchange="this.value = (this.checked)" /> Allow users to use browser GPS in order to display their current position on map - - + Google maps api key: Go to the Google API Console and click ‘Get A Key’

    - + " />

    @@ -334,7 +332,7 @@ - +