diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js
index 9c5ea1d..8bc854e 100644
--- a/WP-GPX-Maps.js
+++ b/WP-GPX-Maps.js
@@ -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',
@@ -365,15 +365,26 @@ Author URI: http://www.pedemontanadelgrappa.it/
{
image = new google.maps.MarkerImage(waypointIcon);
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 = "
" + unescape(descr) + "
";
+ cnt = "" + unescape(descr) + "
";
}
else
{
- cnt = "" + title + "
" + unescape(descr) + "
";
+ cnt = "" + title + "
" + unescape(descr) + "
";
}
+
+ cnt += "
Itinéraire
";
+
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)
@@ -1278,4 +1293,4 @@ Author URI: http://www.pedemontanadelgrappa.it/
return Math.sqrt(dLat * dLat + dLon * dLon);
}
-}( jQuery ));
\ No newline at end of file
+}( jQuery ));
diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php
index 14bc2b2..475d6b4 100644
--- a/wp-gpx-maps.php
+++ b/wp-gpx-maps.php
@@ -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()
diff --git a/wp-gpx-maps_utils.php b/wp-gpx-maps_utils.php
index 1aba4c3..81be0ae 100644
--- a/wp-gpx-maps_utils.php
+++ b/wp-gpx-maps_utils.php
@@ -585,20 +585,41 @@
$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
foreach($nodes as $wpt)
{
- $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));
+ $lat = $wpt['lat'];
+ $lon = $wpt['lon'];
+ $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
+ ));
}
}
}