* 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
This commit is contained in:
bastianonm 2017-02-27 08:47:04 +00:00
parent e2577cb476
commit c87496127f
5 changed files with 51 additions and 66 deletions

View File

@ -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 };
}

View File

@ -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 =

View File

@ -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
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
{
} else if ($uomspeed == '4') /* min/mi */ {
$speed = convertSeconds($speed * 0.037282272);
$uom = " min/mi";
}
else if ($uomspeed == '3') // min/km
{
} else if ($uomspeed == '3') /* min/km */ {
$speed = convertSeconds($speed * 0.06);
$uom = " min/km";
}
else if ($uomspeed == '2') // miles/h
{
} else if ($uomspeed == '2') /* miles/h */ {
$speed *= 2.2369362920544025;
$uom = " mi/h";
}
else if ($uomspeed == '1') // km/h
{
} else if ($uomspeed == '1') /* km/h */ {
$speed *= 3.6;
$uom = " km/h";
}
else // dafault m/s
{
} else /* dafault m/s */ {
$uom = " m/s";
}
if ($addUom == true)
{
if ($addUom == true) {
return number_format ( $speed , 2 , '.' , '' ) . $uom;
}
else
{
} else {
return number_format ( $speed , 2 , '.' , '' );
}
}
function downloadRemoteFile($remoteFile)

View File

@ -121,7 +121,7 @@ function WP_GPX_Maps_html_page() {
</li><li><b>glinecolorhr</b>: heart rate line color (default is #ff77bd)
</li><li><b>glinecolorcad</b>: cadence line color (default is #beecff)
</li><li><b>glinecolorgrade</b>: grade line color (default is #beecff)
</li><li><b>uomspeed</b>: 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))
</li><li><b>uomspeed</b>: 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)
</li><li><b>chartFrom1</b>: minimun value for altitude chart
</li><li><b>chartTo1</b>: maxumin value for altitude chart
</li><li><b>chartFrom2</b>: minimun value for speed chart

View File

@ -36,8 +36,7 @@
$total_time = get_option("wpgpxmaps_summary_total_time");
$usegpsposition = get_option("wpgpxmaps_usegpsposition");
$distanceType = get_option("wpgpxmaps_distance_type");
$distanceType = get_option("wpgpxmaps_distance_type"); $distanceType = get_option("wpgpxmaps_googlemapsv3_apikey");
if (empty($showEle))
$showEle = "true";
@ -103,12 +102,11 @@
<input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if($usegpsposition == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to use browser GPS in order to display their current position on map</i>
</td>
</tr>
</table>
<tr> <th scope="row">Google maps api key:</th> <td> <input name="wpgpxmaps_googlemapsv3_apikey" type="text" id="wpgpxmaps_googlemapsv3_apikey" value="<?php echo get_option('wpgpxmaps_googlemapsv3_apikey'); ?>" style="width:400px" /> <em> Go to the <a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">Google API Console</a> and click &#8216;Get A Key&#8217; </em> </td> </tr> </table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition" />
<input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition,wpgpxmaps_googlemapsv3_apikey" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p>
@ -334,7 +332,7 @@
<option value="2" <?php if ($uomSpeed == '2') echo 'selected'; ?>>miles/h</option>
<option value="3" <?php if ($uomSpeed == '3') echo 'selected'; ?>>min/km</option>
<option value="4" <?php if ($uomSpeed == '4') echo 'selected'; ?>>min/miles</option>
<option value="5" <?php if ($uomSpeed == '5') echo 'selected'; ?>>Nautical Miles/Hour (Knots)</option>
<option value="5" <?php if ($uomSpeed == '5') echo 'selected'; ?>>Nautical Miles/Hour (Knots)</option> <option value="6" <?php if ($uomSpeed == '6') echo 'selected'; ?>>min/100 meters</option>
</select>
</td>
</tr>