This commit is contained in:
bastianonm 2011-12-29 09:54:00 +00:00
parent c38faca77c
commit 39f93d35a8
6 changed files with 77 additions and 36 deletions

View File

@ -3,6 +3,7 @@
WP-GPX-Maps
*/
var loc_en =
{
"length" : "Length",
@ -104,13 +105,32 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
map.fitBounds(bounds);
var first = getItemFromArray(mapData,0)
var current = new google.maps.MarkerImage("http://maps.google.com/mapfiles/kml/pal4/icon25.png",
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(16, 16)
);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(first[0], first[1]),
title:"Start",
icon: "/wp-content/plugins/wp-gpx-maps/img/map_start.png",
icon: current,
map: map,
zIndex: 10
});
google.maps.event.addListener(poly,'mouseover',function(event){
if (marker)
{
marker.setPosition(event.latLng);
marker.setTitle("Current Position");
if ( chart )
{
var ci = getClosestIndex(mapData,event.latLng.Qa,event.latLng.Ra);
var r = chart.setSelection([{'row': parseInt(ci) + 1}]);
}
}
});
}
// Print Graph
@ -130,42 +150,20 @@ function _wpgpxmaps(targhetId,mapType,mapData,graphData,waypoints)
};
chart.draw(data, options);
var current = new google.maps.MarkerImage('/wp-content/plugins/wp-gpx-maps/img/map_current.png',
new google.maps.Size(32, 32),
new google.maps.Point(0,0),
new google.maps.Point(8, 0)
);
google.visualization.events.addListener(chart, 'onmouseover', function (e) {
var r = e['row'];
chart.setSelection([e]);
if (marker)
{
var point = getItemFromArray(mapData,r)
marker.setPosition(new google.maps.LatLng(point[0],point[1]));
marker.setIcon(current);
marker.setTitle("Current Position");
}
});
google.visualization.events.addListener(chart, 'onmouseout', function (e) {
if (marker)
{
if (chart.getSelection() != '')
{
var r = chart.getSelection()[0]['row'];
var point = getItemFromArray(mapData,r)
marker.setPosition(new google.maps.LatLng(point[0], point[1]));
marker.setIcon(current);
marker.setTitle("Graph Selection");
}
else
{
var point = getItemFromArray(mapData,0)
marker.setPosition(new google.maps.LatLng(point[0], point[1]));
marker.setIcon("/wp-content/plugins/wp-gpx-maps/img/map_start.png");
marker.setTitle("Graph Selection");
}
}
});
//google.visualization.events.addListener(chart, 'onmouseout', function (e) {
//chart.setSelection([e]);
//});
}
else
{
@ -186,12 +184,10 @@ function addWayPoint(map, image, shadow, lat, lon, title, descr)
zIndex: 5
});
google.maps.event.addListener(m, 'mouseover', function() {
if (infowindow)
{
infowindow.close();
}
infowindow = new google.maps.InfoWindow({
content: "<b>" + title + "</b></br />" + descr
});
@ -210,3 +206,32 @@ function getItemFromArray(arr,index)
return [0,0];
}
}
function getClosestIndex(points,lat,lon)
{
var dd=10000;
var ii=0;
for(var i in points)
{
var d = dist(points[i][0], points[i][1], lat, lon);
if (d<dd)
{
ii=i;
dd=d;
}
}
return ii;
}
function dist(lat1,lon1,lat2,lon2)
{
// mathematically not correct but fast
var dLat = (lat2-lat1);
var dLon = (lon2-lon1);
var a = Math.sin(dLat) * Math.sin(dLat) +
Math.sin(dLon) * Math.sin(dLon) * Math.cos(lat1) * Math.cos(lat2);
return Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=basti
Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
Requires at least: 2.0.0
Tested up to: 3.3
Stable tag: 1.0.7
Stable tag: 1.0.8
License: GPLv2 or later
Draws a gpx track with altitude graph
@ -68,6 +68,9 @@ Yes!
2. Admin area
== Changelog ==
= 1.0.8 =
* New icons (from google maps)
* Added interactivity over the map
= 1.0.7 =
* Added waypoints support
* New icons
@ -89,6 +92,7 @@ Yes!
* Initial release.
== Upgrade Notice ==
= 1.0.8 =
= 1.0.7 =
* Added waypoints support. To enable this feature please check the plugin settings
= 1.0.6 =

View File

@ -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.7
Version: 1.0.8
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
License: GPL
@ -91,6 +91,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$r = rand(1,5000000);
$gpx = trim($gpx);
$points = getPoints($gpx);
$points_maps = '';
$points_graph = '';
@ -134,7 +136,6 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
return $output;
}
function unescape($value)
{
$value = str_replace("'", "\'", $value);

View File

@ -103,12 +103,15 @@ function WP_GPX_Maps_html_page() {
<div class="tablenav top">
<form enctype="multipart/form-data" method="POST">
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="submitgpx(this);" />
<?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";
echo "File <b>". basename( $_FILES['uploadedfile']['name']). "</b> has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
@ -181,6 +184,14 @@ function WP_GPX_Maps_html_page() {
</div>
<script type="text/javascript">
function submitgpx(el)
{
var newEl = document.createElement('span');
newEl.innerHTML = 'Uploading file...';
el.parentNode.insertBefore(newEl,el.nextSibling);
el.parentNode.submit()
}
function delgpx(file)
{
if (confirm('Delte this file: ' + file + '?'))