This commit is contained in:
bastianonm 2015-12-15 09:46:08 +00:00
parent 798d58d9c2
commit f1a3523a32
3 changed files with 63 additions and 27 deletions

View File

@ -2,7 +2,7 @@
Plugin Name: WP-GPX-Maps
Plugin URI: http://www.devfarm.it/
Description: Draws a gpx track with altitude graph
Version: 1.3.3
Version: 1.3.9
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
*/
@ -347,7 +347,7 @@ Author URI: http://www.pedemontanadelgrappa.it/
// Print WayPoints
if (waypoints != '')
if (!jQuery.isEmptyObject(waypoints))
{
var image = new google.maps.MarkerImage('http://maps.google.com/mapfiles/ms/micons/flag.png',
@ -367,13 +367,24 @@ Author URI: http://www.pedemontanadelgrappa.it/
shadow = '';
}
for (i=0; i < waypoints.length; i++)
{
var lat= waypoints[i][0];
var lon= waypoints[i][1];
addWayPoint(map, image, shadow, lat, lon, waypoints[i][2], waypoints[i][3]);
bounds.extend(new google.maps.LatLng(lat, lon));
jQuery.each(waypoints, function(i, wpt) {
var lat= wpt.lat;
var lon= wpt.lon;
var sym= wpt.sym;
var typ= wpt.type;
var wim= image;
var wsh= shadow;
if (wpt.img) {
wim = new google.maps.MarkerImage(wpt.img);
wsh = '';
}
addWayPoint(map, wim, wsh, lat, lon, wpt.name, wpt.desc);
bounds.extend(new google.maps.LatLng(lat, lon));
});
}
// Print Images
@ -1183,31 +1194,35 @@ Author URI: http://www.pedemontanadelgrappa.it/
zIndex: 5
});
google.maps.event.addListener(m, 'mouseover', function() {
google.maps.event.addListener(m, 'click', function() {
if (infowindow)
{
infowindow.close();
}
var cnt = '';
if (title=='')
{
cnt = "<div style='text-align:center;'>" + unescape(descr) + "</div>";
cnt = "<div>" + unescape(descr) + "</div>";
}
else
{
cnt = "<div style='font-size:0.8em; text-align:center;'><b>" + title + "</b><br />" + unescape(descr) + "</div>";
cnt = "<div><b>" + title + "</b><br />" + unescape(descr) + "</div>";
}
cnt += "<br /><p><a href='https://maps.google.com?daddr=" + lat + "," + lon + "' target='_blank'>Itin&eacute;raire</a></p>";
infowindow = new google.maps.InfoWindow({ content: cnt});
infowindow.open(map,m);
});
/*
google.maps.event.addListener(m, "mouseout", function () {
if (infowindow)
{
infowindow.close();
}
});
*/
}
function getItemFromArray(arr,index)

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.8
Version: 1.3.9
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
*/
@ -51,7 +51,7 @@ function enqueue_WP_GPX_Maps_scripts()
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?sensor=false', 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.5");
wp_enqueue_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.3.8");
}
function print_WP_GPX_Maps_styles()

View File

@ -585,6 +585,8 @@
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt');
global $wpdb;
if ( count($nodes) > 0 )
{
// normal case
@ -592,13 +594,32 @@
{
$lat = $wpt['lat'];
$lon = $wpt['lon'];
$ele = $wpt->ele;
$time = $wpt->time;
$name = $wpt->name;
$desc = $wpt->desc;
$sym = $wpt->sym;
$type = $wpt->type;
array_push($points, array((float)$lat,(float)$lon,(float)$ele,$time,$name,$desc,$sym,$type));
$ele = (string) $wpt->ele;
$time = (string) $wpt->time;
$name = (string) $wpt->name;
$desc = (string) $wpt->desc;
$sym = (string) $wpt->sym;
$type = (string) $wpt->type;
$img = '';
$img_name = 'map-marker-' . $sym;
$query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_name LIKE '{$img_name}' AND post_type LIKE 'attachment'";
$img_id = $wpdb->get_var($query);
if (!is_null($img_id)) {
$img = wp_get_attachment_url($img_id);
}
array_push($points, array(
"lat" => (float)$lat,
"lon" => (float)$lon,
"ele" => (float)$ele,
"time" => $time,
"name" => $name,
"desc" => $desc,
"sym" => $sym,
"type" => $type,
"img" => $img
));
}
}
}