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 Name: WP-GPX-Maps
Plugin URI: http://www.devfarm.it/ Plugin URI: http://www.devfarm.it/
Description: Draws a gpx track with altitude graph Description: Draws a gpx track with altitude graph
Version: 1.3.3 Version: 1.3.9
Author: Bastianon Massimo Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/ Author URI: http://www.pedemontanadelgrappa.it/
*/ */
@ -347,7 +347,7 @@ Author URI: http://www.pedemontanadelgrappa.it/
// Print WayPoints // Print WayPoints
if (waypoints != '') if (!jQuery.isEmptyObject(waypoints))
{ {
var image = new google.maps.MarkerImage('http://maps.google.com/mapfiles/ms/micons/flag.png', var image = new google.maps.MarkerImage('http://maps.google.com/mapfiles/ms/micons/flag.png',
@ -365,15 +365,26 @@ Author URI: http://www.pedemontanadelgrappa.it/
{ {
image = new google.maps.MarkerImage(waypointIcon); image = new google.maps.MarkerImage(waypointIcon);
shadow = ''; 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 // Print Images
@ -1183,31 +1194,35 @@ Author URI: http://www.pedemontanadelgrappa.it/
zIndex: 5 zIndex: 5
}); });
google.maps.event.addListener(m, 'mouseover', function() { google.maps.event.addListener(m, 'click', function() {
if (infowindow) if (infowindow)
{ {
infowindow.close(); infowindow.close();
} }
var cnt = ''; var cnt = '';
if (title=='') if (title=='')
{ {
cnt = "<div style='text-align:center;'>" + unescape(descr) + "</div>"; cnt = "<div>" + unescape(descr) + "</div>";
} }
else 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 = new google.maps.InfoWindow({ content: cnt});
infowindow.open(map,m); infowindow.open(map,m);
}); });
/*
google.maps.event.addListener(m, "mouseout", function () { google.maps.event.addListener(m, "mouseout", function () {
if (infowindow) if (infowindow)
{ {
infowindow.close(); infowindow.close();
} }
}); });
*/
} }
function getItemFromArray(arr,index) function getItemFromArray(arr,index)
@ -1278,4 +1293,4 @@ Author URI: http://www.pedemontanadelgrappa.it/
return Math.sqrt(dLat * dLat + dLon * dLon); return Math.sqrt(dLat * dLat + dLon * dLon);
} }
}( jQuery )); }( jQuery ));

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps Plugin Name: WP-GPX-Maps
Plugin URI: http://www.devfarm.it/ Plugin URI: http://www.devfarm.it/
Description: Draws a GPX track with altitude chart Description: Draws a GPX track with altitude chart
Version: 1.3.8 Version: 1.3.9
Author: Bastianon Massimo Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/ Author URI: http://www.pedemontanadelgrappa.it/
*/ */
@ -51,7 +51,7 @@ function enqueue_WP_GPX_Maps_scripts()
wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?sensor=false', null, null); 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( '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() function print_WP_GPX_Maps_styles()

View File

@ -585,20 +585,41 @@
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1'); $gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt'); $nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt');
global $wpdb;
if ( count($nodes) > 0 ) if ( count($nodes) > 0 )
{ {
// normal case // normal case
foreach($nodes as $wpt) foreach($nodes as $wpt)
{ {
$lat = $wpt['lat']; $lat = $wpt['lat'];
$lon = $wpt['lon']; $lon = $wpt['lon'];
$ele = $wpt->ele; $ele = (string) $wpt->ele;
$time = $wpt->time; $time = (string) $wpt->time;
$name = $wpt->name; $name = (string) $wpt->name;
$desc = $wpt->desc; $desc = (string) $wpt->desc;
$sym = $wpt->sym; $sym = (string) $wpt->sym;
$type = $wpt->type; $type = (string) $wpt->type;
array_push($points, array((float)$lat,(float)$lon,(float)$ele,$time,$name,$desc,$sym,$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
));
} }
} }
} }