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',
@ -367,13 +367,24 @@ Author URI: http://www.pedemontanadelgrappa.it/
shadow = ''; shadow = '';
} }
for (i=0; i < waypoints.length; i++) jQuery.each(waypoints, function(i, wpt) {
{
var lat= waypoints[i][0]; var lat= wpt.lat;
var lon= waypoints[i][1]; var lon= wpt.lon;
addWayPoint(map, image, shadow, lat, lon, waypoints[i][2], waypoints[i][3]); var sym= wpt.sym;
bounds.extend(new google.maps.LatLng(lat, lon)); 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)

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,6 +585,8 @@
$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
@ -592,13 +594,32 @@
{ {
$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
));
} }
} }
} }