This commit is contained in:
parent
c69874067a
commit
5720ab8d00
|
@ -46,7 +46,7 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
|||
if (marker)
|
||||
{
|
||||
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) {
|
||||
|
@ -56,13 +56,12 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
|||
{
|
||||
var r = chart.getSelection()[0]['row'];
|
||||
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");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (mapData != '')
|
||||
{
|
||||
} else { el_chart.style.display='none'; }
|
||||
if (mapData != '') {
|
||||
var points = [];
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
for(var i in mapData)
|
||||
|
@ -83,7 +82,7 @@ function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
|||
var first = getItemFromArray(mapData,0)
|
||||
var marker = new google.maps.Marker({
|
||||
position: new google.maps.LatLng(first[0], first[1]),
|
||||
title:"Hello World!"
|
||||
title:"Start"
|
||||
});
|
||||
marker.setMap(map);
|
||||
}
|
||||
|
|
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
|
||||
Requires at least: 2.0.0
|
||||
Tested up to: 3.3
|
||||
Stable tag: 1.0.3
|
||||
Stable tag: 1.0.4
|
||||
License: GPLv2 or later
|
||||
|
||||
Draws a gpx track with altitude graph
|
||||
|
||||
== 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
|
||||
|
||||
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>,
|
||||
<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 ==
|
||||
|
||||
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. Add the shortcode [sgpx gpx=">relative path to your gpx<"]
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= what are all available shortcode attributes? =
|
||||
|
||||
The attributes are:
|
||||
|
||||
1. gpx: relative path to gpx
|
||||
|
||||
1. width: width in pixels
|
||||
|
||||
1. mheight: map height
|
||||
|
||||
1. gheight: graph height
|
||||
|
||||
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]
|
||||
|
||||
= What happening if I've a very large gpx? =
|
||||
This plugin will print a small amout of points to to speedup javascript and pageload.
|
||||
|
||||
= Is it free? =
|
||||
Yes!
|
||||
|
||||
|
@ -41,6 +66,9 @@ Yes!
|
|||
2. Screenshot Admin area
|
||||
|
||||
== Changelog ==
|
||||
= 1.0.4 =
|
||||
* Fixed Upload file error
|
||||
* Added support for Garmin gpx (http://www.garmin.com/xmlschemas/GpxExtensions/v3 namespace)
|
||||
= 1.0.3 =
|
||||
* Added Settings link on plugins list
|
||||
* Added attributes width, mheight, gheight, mtype on shortcode.
|
||||
|
@ -52,6 +80,7 @@ Yes!
|
|||
* Initial release.
|
||||
|
||||
== Upgrade Notice ==
|
||||
= 1.0.4 =
|
||||
= 1.0.3 =
|
||||
= 1.0.2 =
|
||||
= 1.0.1 =
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: WP-GPX-Maps
|
||||
Plugin URI: http://www.darwinner.it/
|
||||
Description: Draws a gpx track with altitude graph
|
||||
Version: 1.0.3
|
||||
Version: 1.0.4
|
||||
Author: Bastianon Massimo
|
||||
Author URI: http://www.pedemontanadelgrappa.it/
|
||||
License: GPL
|
||||
|
@ -90,13 +90,11 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
|||
foreach ($points as $p) {
|
||||
$points_maps .= "[".(float)$p[0].",".(float)$p[1]."],";
|
||||
$points_graph .= "[".(float)$p[3].",".(float)$p[2]."],";
|
||||
}
|
||||
} //all the points are [0,0] $points_graph = preg_replace("/^(\[0,0\],)+$/", "", $points_graph);
|
||||
$p="/,$/";
|
||||
$points_maps = preg_replace($p, "", $points_maps);
|
||||
$points_graph = preg_replace($p, "", $points_graph);
|
||||
|
||||
echo
|
||||
'
|
||||
$points_graph = preg_replace($p, "", $points_graph); if (preg_match("/^(\[0,0\],?)+$/", $points_graph)) { $points_graph = ""; }
|
||||
echo '
|
||||
<div id="wpgpxmaps_'.$r.'" style="clear:both;">
|
||||
<div id="map_'.$r.'" style="width:'.$w.'; height:'.$mh.'"></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.'];
|
||||
wpgpxmaps("'.$r.'",\''.$mt.'\',m_'.$r.',c_'.$r.');
|
||||
});
|
||||
|
||||
</script>';
|
||||
}
|
||||
|
||||
|
|
|
@ -19,12 +19,41 @@
|
|||
|
||||
if (file_exists($realGpxPath))
|
||||
{
|
||||
$points = parseXml($realGpxPath, $gpxOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($points, array((float)0,(float)0,(float)0,(float)0));
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
$gpx = simplexml_load_file($realGpxPath);
|
||||
$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
|
||||
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
|
||||
function parseXml($filePath, $gpxOffset)
|
||||
{
|
||||
|
||||
foreach($gpx->xpath('//trkpt | //10:trkpt | //11:trkpt') as $trkpt){
|
||||
$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'];
|
||||
$lon = $trkpt['lon'];
|
||||
$ele = $trkpt->ele;
|
||||
|
@ -57,24 +86,59 @@
|
|||
$lastLon=$lon;
|
||||
$lastEle=$ele;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($points, array((float)0,(float)0,(float)0,(float)0));
|
||||
}
|
||||
// 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]);
|
||||
|
||||
$nodes = $gpx->xpath('//gpxx:rpt');
|
||||
|
||||
if ( count($nodes) > 0 )
|
||||
{
|
||||
|
||||
// Garmin case
|
||||
foreach($nodes as $rpt)
|
||||
{
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
function toRadians($degrees)
|
||||
{
|
||||
return $degrees * 3.1415926535897932385 / 180;
|
||||
|
@ -89,4 +153,6 @@
|
|||
$dist = 2 * 3958.75 * atan2(sqrt($a), sqrt(1 - (float) $a));
|
||||
return sqrt(pow($dist * 1609.00, 2) + pow((float) $lat1 - (float)$lat2, 2));
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -99,13 +99,9 @@ function WP_GPX_Maps_html_page() {
|
|||
|
||||
<div class="tablenav top">
|
||||
<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()" />
|
||||
<?php
|
||||
if ( isset($_FILES['uploadedfile']) )
|
||||
{
|
||||
$target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']);
|
||||
if (preg_match($gpxRegEx,$target_path ))
|
||||
if ( isset($_FILES['uploadedfile']) ) { $target_path = $realGpxPath ."/". basename( $_FILES['uploadedfile']['name']); if (preg_match($gpxRegEx, $target_path))
|
||||
{
|
||||
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
|
||||
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
|
||||
|
|
Loading…
Reference in New Issue