This commit is contained in:
parent
c69874067a
commit
5720ab8d00
|
@ -46,7 +46,7 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
||||||
if (marker)
|
if (marker)
|
||||||
{
|
{
|
||||||
var point = getItemFromArray(mapData,r)
|
var point = getItemFromArray(mapData,r)
|
||||||
marker.setPosition(new google.maps.LatLng(point[0],point[1]));
|
marker.setPosition(new google.maps.LatLng(point[0],point[1])); marker.setTitle("Current Position");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
google.visualization.events.addListener(chart, 'onmouseout', function (e) {
|
google.visualization.events.addListener(chart, 'onmouseout', function (e) {
|
||||||
|
@ -56,13 +56,12 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
||||||
{
|
{
|
||||||
var r = chart.getSelection()[0]['row'];
|
var r = chart.getSelection()[0]['row'];
|
||||||
var point = getItemFromArray(mapData,r)
|
var point = getItemFromArray(mapData,r)
|
||||||
marker.setPosition(new google.maps.LatLng(point[0], point[1]));
|
marker.setPosition(new google.maps.LatLng(point[0], point[1])); marker.setTitle("Graph Selection");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else { el_chart.style.display='none'; }
|
||||||
if (mapData != '')
|
if (mapData != '') {
|
||||||
{
|
|
||||||
var points = [];
|
var points = [];
|
||||||
var bounds = new google.maps.LatLngBounds();
|
var bounds = new google.maps.LatLngBounds();
|
||||||
for(var i in mapData)
|
for(var i in mapData)
|
||||||
|
@ -83,10 +82,10 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
||||||
var first = getItemFromArray(mapData,0)
|
var first = getItemFromArray(mapData,0)
|
||||||
var marker = new google.maps.Marker({
|
var marker = new google.maps.Marker({
|
||||||
position: new google.maps.LatLng(first[0], first[1]),
|
position: new google.maps.LatLng(first[0], first[1]),
|
||||||
title:"Hello World!"
|
title:"Start"
|
||||||
});
|
});
|
||||||
marker.setMap(map);
|
marker.setMap(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getItemFromArray(arr,index)
|
function getItemFromArray(arr,index)
|
||||||
{
|
{
|
||||||
|
|
35
readme.txt
35
readme.txt
|
@ -4,35 +4,60 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=basti
|
||||||
Tags: maps, gpx, gps, graph, google maps, google chart
|
Tags: maps, gpx, gps, graph, google maps, google chart
|
||||||
Requires at least: 2.0.0
|
Requires at least: 2.0.0
|
||||||
Tested up to: 3.3
|
Tested up to: 3.3
|
||||||
Stable tag: 1.0.3
|
Stable tag: 1.0.4
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
|
|
||||||
Draws a gpx track with altitude graph
|
Draws a gpx track with altitude graph
|
||||||
|
|
||||||
== Description ==
|
== Description ==
|
||||||
This plugin has, as input, the GPX file with the track you've made. As output it shows the map of the track, fixed with an altitude graph.
|
This plugin has, as input, the GPX file with the track you've made. As output it shows the map of the track, fixed with an altitude graph (where aviable).
|
||||||
|
|
||||||
- iphone/ipad/ipod Compatible
|
- iphone/ipad/ipod Compatible
|
||||||
|
|
||||||
Try this plugin on <a href="http://www.pedemontanadelgrappa.it/category/mappe/">http://www.pedemontanadelgrappa.it/category/mappe/</a>
|
Try this plugin on <a href="http://www.pedemontanadelgrappa.it/category/mappe/">http://www.pedemontanadelgrappa.it/category/mappe/</a>
|
||||||
|
|
||||||
Thanks to: <a href="http://www.securcube.net/">www.securcube.net</a>, <a href="http://www.darwinner.it/">www.darwinner.it</a>, <a href="http://www.pedemontanadelgrappa.it/">www.pedemontanadelgrappa.it</a>,
|
Thanks to: <a href="http://www.securcube.net/">www.securcube.net</a>, <a href="http://www.darwinner.it/">www.darwinner.it</a>, <a href="http://www.pedemontanadelgrappa.it/">www.pedemontanadelgrappa.it</a>,
|
||||||
<a href="http://www.darwinner.it/featured/wp-gpx-maps/">Bugs, problems, thanks and anything else here!</a>
|
<a href="http://www.darwinner.it/featured/wp-gpx-maps/">
|
||||||
|
|
||||||
|
Bugs, problems, thanks and anything else here!</a>
|
||||||
|
|
||||||
|
Supported gpx namespace are:
|
||||||
|
|
||||||
|
1. http://www.topografix.com/GPX/1/0
|
||||||
|
|
||||||
|
1. http://www.topografix.com/GPX/1/1
|
||||||
|
|
||||||
|
1. http://www.garmin.com/xmlschemas/GpxExtensions/v3
|
||||||
|
|
||||||
== Installation ==
|
== Installation ==
|
||||||
|
|
||||||
1. Use the classic wordpress plugin installer or copy the plugins folder to the `/wp-content/plugins/` directory
|
1. Use the classic wordpress plugin installer or copy the plugins folder to the `/wp-content/plugins/` directory
|
||||||
|
|
||||||
1. Activate the plugin through the 'Plugins' menu in WordPress
|
1. Activate the plugin through the 'Plugins' menu in WordPress
|
||||||
|
|
||||||
1. Add the shortcode [sgpx gpx=">relative path to your gpx<"]
|
1. Add the shortcode [sgpx gpx=">relative path to your gpx<"]
|
||||||
|
|
||||||
== Frequently Asked Questions ==
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
= what are all available shortcode attributes? =
|
= what are all available shortcode attributes? =
|
||||||
|
|
||||||
The attributes are:
|
The attributes are:
|
||||||
|
|
||||||
1. gpx: relative path to gpx
|
1. gpx: relative path to gpx
|
||||||
|
|
||||||
1. width: width in pixels
|
1. width: width in pixels
|
||||||
|
|
||||||
1. mheight: map height
|
1. mheight: map height
|
||||||
|
|
||||||
1. gheight: graph height
|
1. gheight: graph height
|
||||||
|
|
||||||
1. mtype: map aviable types are: HYBRID, ROADMAP, SATELLITE, TERRAIN
|
1. mtype: map aviable types are: HYBRID, ROADMAP, SATELLITE, TERRAIN
|
||||||
|
|
||||||
shortcode with all the attributes : [sgpx gpx=">relative path to your gpx<" width=100% mheight=300px gheight=200px mtype=SATELLITE]
|
shortcode with all the attributes : [sgpx gpx=">relative path to your gpx<" width=100% mheight=300px gheight=200px mtype=SATELLITE]
|
||||||
|
|
||||||
= What happening if I've a very large gpx? =
|
= What happening if I've a very large gpx? =
|
||||||
This plugin will print a small amout of points to to speedup javascript and pageload.
|
This plugin will print a small amout of points to to speedup javascript and pageload.
|
||||||
|
|
||||||
= Is it free? =
|
= Is it free? =
|
||||||
Yes!
|
Yes!
|
||||||
|
|
||||||
|
@ -41,6 +66,9 @@ Yes!
|
||||||
2. Screenshot Admin area
|
2. Screenshot Admin area
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
= 1.0.4 =
|
||||||
|
* Fixed Upload file error
|
||||||
|
* Added support for Garmin gpx (http://www.garmin.com/xmlschemas/GpxExtensions/v3 namespace)
|
||||||
= 1.0.3 =
|
= 1.0.3 =
|
||||||
* Added Settings link on plugins list
|
* Added Settings link on plugins list
|
||||||
* Added attributes width, mheight, gheight, mtype on shortcode.
|
* Added attributes width, mheight, gheight, mtype on shortcode.
|
||||||
|
@ -52,6 +80,7 @@ Yes!
|
||||||
* Initial release.
|
* Initial release.
|
||||||
|
|
||||||
== Upgrade Notice ==
|
== Upgrade Notice ==
|
||||||
|
= 1.0.4 =
|
||||||
= 1.0.3 =
|
= 1.0.3 =
|
||||||
= 1.0.2 =
|
= 1.0.2 =
|
||||||
= 1.0.1 =
|
= 1.0.1 =
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: WP-GPX-Maps
|
Plugin Name: WP-GPX-Maps
|
||||||
Plugin URI: http://www.darwinner.it/
|
Plugin URI: http://www.darwinner.it/
|
||||||
Description: Draws a gpx track with altitude graph
|
Description: Draws a gpx track with altitude graph
|
||||||
Version: 1.0.3
|
Version: 1.0.4
|
||||||
Author: Bastianon Massimo
|
Author: Bastianon Massimo
|
||||||
Author URI: http://www.pedemontanadelgrappa.it/
|
Author URI: http://www.pedemontanadelgrappa.it/
|
||||||
License: GPL
|
License: GPL
|
||||||
|
@ -90,13 +90,11 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
||||||
foreach ($points as $p) {
|
foreach ($points as $p) {
|
||||||
$points_maps .= "[".(float)$p[0].",".(float)$p[1]."],";
|
$points_maps .= "[".(float)$p[0].",".(float)$p[1]."],";
|
||||||
$points_graph .= "[".(float)$p[3].",".(float)$p[2]."],";
|
$points_graph .= "[".(float)$p[3].",".(float)$p[2]."],";
|
||||||
}
|
} //all the points are [0,0] $points_graph = preg_replace("/^(\[0,0\],)+$/", "", $points_graph);
|
||||||
$p="/,$/";
|
$p="/,$/";
|
||||||
$points_maps = preg_replace($p, "", $points_maps);
|
$points_maps = preg_replace($p, "", $points_maps);
|
||||||
$points_graph = preg_replace($p, "", $points_graph);
|
$points_graph = preg_replace($p, "", $points_graph); if (preg_match("/^(\[0,0\],?)+$/", $points_graph)) { $points_graph = ""; }
|
||||||
|
echo '
|
||||||
echo
|
|
||||||
'
|
|
||||||
<div id="wpgpxmaps_'.$r.'" style="clear:both;">
|
<div id="wpgpxmaps_'.$r.'" style="clear:both;">
|
||||||
<div id="map_'.$r.'" style="width:'.$w.'; height:'.$mh.'"></div>
|
<div id="map_'.$r.'" style="width:'.$w.'; height:'.$mh.'"></div>
|
||||||
<div id="chart_'.$r.'" class="plot" style="width:'.$w.'; height:'.$gh.'"></div>
|
<div id="chart_'.$r.'" class="plot" style="width:'.$w.'; height:'.$gh.'"></div>
|
||||||
|
@ -107,7 +105,6 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
||||||
var c_'.$r.' = ['.$points_graph.'];
|
var c_'.$r.' = ['.$points_graph.'];
|
||||||
wpgpxmaps("'.$r.'",\''.$mt.'\',m_'.$r.',c_'.$r.');
|
wpgpxmaps("'.$r.'",\''.$mt.'\',m_'.$r.',c_'.$r.');
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,44 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'/wp-content/')).$gpxPath;
|
$realGpxPath = substr (__FILE__, 0, strrpos(__FILE__,'/wp-content/')).$gpxPath;
|
||||||
|
|
||||||
if (file_exists($realGpxPath))
|
if (file_exists($realGpxPath))
|
||||||
{
|
{
|
||||||
|
$points = parseXml($realGpxPath, $gpxOffset);
|
||||||
$gpx = simplexml_load_file($realGpxPath);
|
}
|
||||||
$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
|
else
|
||||||
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
|
{
|
||||||
|
array_push($points, array((float)0,(float)0,(float)0,(float)0));
|
||||||
foreach($gpx->xpath('//trkpt | //10:trkpt | //11:trkpt') as $trkpt){
|
}
|
||||||
|
// riduco l'array a circa 200 punti per non appensantire la pagina(mappa e grafico)!
|
||||||
|
$count=sizeof($points);
|
||||||
|
if ($count>200)
|
||||||
|
{
|
||||||
|
$f = round($count/200);
|
||||||
|
if ($f>1)
|
||||||
|
for($i=$count;$i>0;$i--)
|
||||||
|
if ($i % $f != 0)
|
||||||
|
unset($points[$i]);
|
||||||
|
}
|
||||||
|
return $points;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseXml($filePath, $gpxOffset)
|
||||||
|
{
|
||||||
|
|
||||||
|
$points = array();
|
||||||
|
$gpx = simplexml_load_file($filePath);
|
||||||
|
$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
|
||||||
|
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
|
||||||
|
$gpx->registerXPathNamespace('gpxx', 'http://www.garmin.com/xmlschemas/GpxExtensions/v3');
|
||||||
|
|
||||||
|
$nodes = $gpx->xpath('//trkpt | //10:trkpt | //11:trkpt');
|
||||||
|
|
||||||
|
if ( count($nodes) > 0 )
|
||||||
|
{
|
||||||
|
// normal case
|
||||||
|
foreach($nodes as $trkpt)
|
||||||
|
{
|
||||||
$lat = $trkpt['lat'];
|
$lat = $trkpt['lat'];
|
||||||
$lon = $trkpt['lon'];
|
$lon = $trkpt['lon'];
|
||||||
$ele = $trkpt->ele;
|
$ele = $trkpt->ele;
|
||||||
|
@ -57,28 +86,63 @@
|
||||||
$lastLon=$lon;
|
$lastLon=$lon;
|
||||||
$lastEle=$ele;
|
$lastEle=$ele;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array_push($points, array((float)0,(float)0,(float)0,(float)0));
|
|
||||||
}
|
$nodes = $gpx->xpath('//gpxx:rpt');
|
||||||
// riduco l'array a circa 200 punti per non appensantire la pagina(mappa e grafico)!
|
|
||||||
$count=sizeof($points);
|
if ( count($nodes) > 0 )
|
||||||
if ($count>200)
|
{
|
||||||
{
|
|
||||||
$f = round($count/200);
|
// Garmin case
|
||||||
if ($f>1)
|
foreach($nodes as $rpt)
|
||||||
for($i=$count;$i>0;$i--)
|
{
|
||||||
if ($i % $f != 0)
|
|
||||||
unset($points[$i]);
|
$lat = $rpt['lat'];
|
||||||
|
$lon = $rpt['lon'];
|
||||||
|
if ($lastLat == 0 && $lastLon == 0)
|
||||||
|
{
|
||||||
|
//Base Case
|
||||||
|
array_push($points, array((float)$lat,(float)$lon,null,null));
|
||||||
|
$lastLat=$lat;
|
||||||
|
$lastLon=$lon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Normal Case
|
||||||
|
$offset = calculateDistance($lat, $lon, 0,$lastLat, $lastLon, 0);
|
||||||
|
$dist = $dist + $offset;
|
||||||
|
if (((float) $offset + (float) $lastOffset) > $gpxOffset)
|
||||||
|
{
|
||||||
|
//Bigger Offset -> write coordinate
|
||||||
|
$lastOffset=0;
|
||||||
|
array_push($points, array((float)$lat,(float)$lon,null,null));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Smoller Offset -> continue..
|
||||||
|
$lastOffset= (float) $lastOffset + (float) $offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lastLat=$lat;
|
||||||
|
$lastLon=$lon;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "Gpx Empty or not supported!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $points;
|
return $points;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toRadians($degrees)
|
function toRadians($degrees)
|
||||||
{
|
{
|
||||||
return $degrees * 3.1415926535897932385 / 180;
|
return $degrees * 3.1415926535897932385 / 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateDistance($lat1,$lon1,$ele1,$lat2,$lon2,$ele2)
|
function calculateDistance($lat1,$lon1,$ele1,$lat2,$lon2,$ele2)
|
||||||
{
|
{
|
||||||
|
@ -89,4 +153,6 @@
|
||||||
$dist = 2 * 3958.75 * atan2(sqrt($a), sqrt(1 - (float) $a));
|
$dist = 2 * 3958.75 * atan2(sqrt($a), sqrt(1 - (float) $a));
|
||||||
return sqrt(pow($dist * 1609.00, 2) + pow((float) $lat1 - (float)$lat2, 2));
|
return sqrt(pow($dist * 1609.00, 2) + pow((float) $lat1 - (float)$lat2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -99,14 +99,10 @@ function WP_GPX_Maps_html_page() {
|
||||||
|
|
||||||
<div class="tablenav top">
|
<div class="tablenav top">
|
||||||
<form enctype="multipart/form-data" method="POST">
|
<form enctype="multipart/form-data" method="POST">
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
|
|
||||||
Choose a file to upload: <input name="uploadedfile" type="file" onchange="this.parentNode.submit()" />
|
Choose a file to upload: <input name="uploadedfile" type="file" onchange="this.parentNode.submit()" />
|
||||||
<?php
|
<?php
|
||||||
if ( isset($_FILES['uploadedfile']) )
|
if ( isset($_FILES['uploadedfile']) ) { $target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']); if (preg_match($gpxRegEx, $target_path))
|
||||||
{
|
{
|
||||||
$target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']);
|
|
||||||
if (preg_match($gpxRegEx,$target_path ))
|
|
||||||
{
|
|
||||||
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
|
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
|
||||||
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
|
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
|
||||||
} else{
|
} else{
|
||||||
|
|
Loading…
Reference in New Issue