2011-12-24 14:37:05 +00:00
|
|
|
|
/*
|
2014-03-14 13:38:36 +00:00
|
|
|
|
Plugin Name: WP-GPX-Maps
|
|
|
|
|
Plugin URI: http://www.devfarm.it/
|
|
|
|
|
Description: Draws a gpx track with altitude graph
|
2018-04-04 06:45:39 +00:00
|
|
|
|
Version: 1.5.05
|
2014-03-14 13:38:36 +00:00
|
|
|
|
Author: Bastianon Massimo
|
2018-03-09 09:02:25 +00:00
|
|
|
|
Author URI: http://www.devfarm.it/
|
2011-12-24 14:37:05 +00:00
|
|
|
|
*/
|
2011-12-29 09:54:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
(function ( $ ) {
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var infowindow;
|
|
|
|
|
var CustomMarker;
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
CustomMarker = function( map, latlng, src, img_w, img_h) {
|
|
|
|
|
this.latlng_ = latlng;
|
|
|
|
|
this.setMap(map);
|
|
|
|
|
this.src_ = src;
|
|
|
|
|
this.img_w_ = img_w;
|
|
|
|
|
this.img_h_ = img_h;
|
|
|
|
|
}
|
2012-03-18 10:44:11 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
CustomMarker.prototype = new google.maps.OverlayView();
|
|
|
|
|
|
|
|
|
|
CustomMarker.prototype.draw = function() {
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
|
|
// Check if the el has been created.
|
|
|
|
|
var el = this.img_;
|
|
|
|
|
if (!el) {
|
|
|
|
|
|
|
|
|
|
this.img_ = document.createElement('img');
|
|
|
|
|
el = this.img_;
|
|
|
|
|
el.style.cssText = "width:"+(this.img_w_/3)+"px;height:"+(this.img_h_/3)+"px;";
|
|
|
|
|
el.setAttribute("class", "myngimages");
|
|
|
|
|
el.setAttribute("lat",this.latlng_.lat());
|
|
|
|
|
el.setAttribute("lon",this.latlng_.lng());
|
|
|
|
|
el.src=this.src_;
|
|
|
|
|
|
|
|
|
|
google.maps.event.addDomListener(el, "click", function(event) {
|
|
|
|
|
google.maps.event.trigger(me, "click", el);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
google.maps.event.addDomListener(el, "mouseover", function(event) {
|
|
|
|
|
var _t = el.style.top.replace('px','');
|
|
|
|
|
var _l = el.style.left.replace('px','');
|
|
|
|
|
jQuery(el).animate({
|
|
|
|
|
height: me.img_h_,
|
|
|
|
|
width : me.img_w_,
|
|
|
|
|
top : _t - (me.img_h_ / 3),
|
|
|
|
|
left : _l - (me.img_w_ / 3),
|
2012-07-06 15:40:38 +00:00
|
|
|
|
'z-index' : 100
|
2012-06-04 12:31:21 +00:00
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
google.maps.event.addDomListener(el, "mouseout", function(event) {
|
|
|
|
|
jQuery(el).animate({
|
|
|
|
|
height: me.img_h_ / 3,
|
|
|
|
|
width: me.img_w_ / 3,
|
|
|
|
|
top : me.orig_top,
|
|
|
|
|
left : me.orig_left,
|
|
|
|
|
'z-index' : 1
|
|
|
|
|
}, 100);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Then add the overlay to the DOM
|
|
|
|
|
var panes = this.getPanes();
|
|
|
|
|
panes.overlayImage.appendChild(el);
|
|
|
|
|
}
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2012-06-04 12:31:21 +00:00
|
|
|
|
// Position the overlay
|
|
|
|
|
var point = this.getProjection().fromLatLngToDivPixel(this.latlng_);
|
|
|
|
|
if (point) {
|
|
|
|
|
el.style.left = point.x + 'px';
|
|
|
|
|
el.style.top = point.y + 'px';
|
|
|
|
|
this.orig_left = point.x;
|
|
|
|
|
this.orig_top = point.y;
|
|
|
|
|
}
|
2012-04-12 14:49:22 +00:00
|
|
|
|
};
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
CustomMarker.prototype.remove = function() {
|
2012-06-04 12:31:21 +00:00
|
|
|
|
// Check if the overlay was on the map and needs to be removed.
|
|
|
|
|
if (this.img_) {
|
|
|
|
|
this.img_.parentNode.removeChild(this.img_);
|
|
|
|
|
this.img_ = null;
|
|
|
|
|
}
|
2012-04-12 14:49:22 +00:00
|
|
|
|
};
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
$.fn.wpgpxmaps = function( params ) {
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var targetId = params.targetId;
|
|
|
|
|
var mapType = params.mapType;
|
|
|
|
|
var mapData = params.mapData;
|
|
|
|
|
var graphDist = params.graphDist;
|
|
|
|
|
var graphEle = params.graphEle;
|
|
|
|
|
var graphSpeed = params.graphSpeed;
|
|
|
|
|
var graphHr = params.graphHr;
|
|
|
|
|
var graphAtemp = params.graphAtemp;
|
|
|
|
|
var graphCad = params.graphCad;
|
|
|
|
|
var graphGrade = params.graphGrade;
|
|
|
|
|
var waypoints = params.waypoints;
|
|
|
|
|
var unit = params.unit;
|
|
|
|
|
var unitspeed = params.unitspeed;
|
|
|
|
|
var color1 = params.color1;
|
|
|
|
|
var color2 = params.color2;
|
|
|
|
|
var color3 = params.color3;
|
|
|
|
|
var color4 = params.color4;
|
|
|
|
|
var color5 = params.color5;
|
|
|
|
|
var color6 = params.color6;
|
|
|
|
|
var color7 = params.color7;
|
|
|
|
|
var chartFrom1 = params.chartFrom1;
|
|
|
|
|
var chartTo1 = params.chartTo1;
|
|
|
|
|
var chartFrom2 = params.chartFrom2;
|
|
|
|
|
var chartTo2 = params.chartTo2;
|
|
|
|
|
var startIcon = params.startIcon;
|
|
|
|
|
var waypointIcon = params.waypointIcon;
|
|
|
|
|
var endIcon = params.endIcon;
|
|
|
|
|
var currentIcon = params.currentIcon;
|
|
|
|
|
var zoomOnScrollWheel = params.zoomOnScrollWheel;
|
|
|
|
|
var lng = params.langs;
|
|
|
|
|
var pluginUrl = params.pluginUrl;
|
|
|
|
|
var usegpsposition = params.usegpsposition;
|
|
|
|
|
var currentpositioncon= params.currentpositioncon;
|
2017-03-01 09:12:32 +00:00
|
|
|
|
var ThunderforestApiKey = params.TFApiKey;
|
2012-06-21 13:29:17 +00:00
|
|
|
|
|
2017-03-01 09:12:32 +00:00
|
|
|
|
var hasThunderforestApiKey = (ThunderforestApiKey + '').length > 0;
|
2018-03-09 09:02:25 +00:00
|
|
|
|
|
|
|
|
|
var _formats=[];
|
2017-03-01 09:12:32 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Unit of measure settings
|
|
|
|
|
var l_s;
|
|
|
|
|
var l_x;
|
|
|
|
|
var l_y;
|
|
|
|
|
var l_grade = { suf : "%", dec : 1 };
|
|
|
|
|
var l_hr = { suf : "", dec : 0 };
|
|
|
|
|
var l_cad = { suf : "", dec : 0 };
|
|
|
|
|
|
|
|
|
|
var el = document.getElementById("wpgpxmaps_" + targetId);
|
|
|
|
|
var el_map = document.getElementById("map_" + targetId);
|
|
|
|
|
var el_chart = document.getElementById("chart_" + targetId);
|
|
|
|
|
var el_report = document.getElementById("report_" + targetId);
|
2014-06-09 13:18:24 +00:00
|
|
|
|
var el_osm_credits = document.getElementById("wpgpxmaps_" + targetId + "_osm_footer");
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
var mapWidth = el_map.style.width;
|
|
|
|
|
|
|
|
|
|
var mapTypeIds = [];
|
|
|
|
|
for(var type in google.maps.MapTypeId) {
|
|
|
|
|
mapTypeIds.push(google.maps.MapTypeId[type]);
|
2012-06-21 13:29:17 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
mapTypeIds.push("OSM1");
|
|
|
|
|
mapTypeIds.push("OSM2");
|
|
|
|
|
mapTypeIds.push("OSM3");
|
|
|
|
|
mapTypeIds.push("OSM4");
|
|
|
|
|
mapTypeIds.push("OSM5");
|
|
|
|
|
mapTypeIds.push("OSM6");
|
|
|
|
|
|
|
|
|
|
var ngImageMarkers = [];
|
|
|
|
|
|
|
|
|
|
switch (mapType)
|
2012-06-21 13:29:17 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
case 'TERRAIN': { mapType = google.maps.MapTypeId.TERRAIN; break;}
|
|
|
|
|
case 'SATELLITE': { mapType = google.maps.MapTypeId.SATELLITE; break;}
|
|
|
|
|
case 'ROADMAP': { mapType = google.maps.MapTypeId.ROADMAP; break;}
|
|
|
|
|
case 'OSM1': { mapType = "OSM1"; break;}
|
|
|
|
|
case 'OSM2': { mapType = "OSM2"; break;}
|
|
|
|
|
case 'OSM3': { mapType = "OSM3"; break;}
|
|
|
|
|
case 'OSM4': { mapType = "OSM4"; break;}
|
|
|
|
|
case 'OSM5': { mapType = "OSM5"; break;}
|
|
|
|
|
case 'OSM6': { mapType = "OSM6"; break;}
|
|
|
|
|
default: { mapType = google.maps.MapTypeId.HYBRID; break;}
|
2012-06-21 13:29:17 +00:00
|
|
|
|
}
|
2014-06-09 13:18:24 +00:00
|
|
|
|
|
|
|
|
|
if ( mapType == "TERRAIN" || mapType == "SATELLITE" || mapType == "ROADMAP" )
|
|
|
|
|
{
|
|
|
|
|
// google maps
|
|
|
|
|
} else {
|
|
|
|
|
// Show OpenStreetMaps credits
|
|
|
|
|
$(el_osm_credits).show();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-14 07:48:30 +00:00
|
|
|
|
var map = new google.maps.Map(el_map, {
|
2014-03-14 13:38:36 +00:00
|
|
|
|
mapTypeId: mapType,
|
|
|
|
|
scrollwheel: (zoomOnScrollWheel == 'true'),
|
|
|
|
|
mapTypeControlOptions: {
|
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
|
|
|
|
|
mapTypeIds: mapTypeIds
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
map.mapTypes.set("OSM1", new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function(coord, zoom) {
|
2017-06-22 07:27:49 +00:00
|
|
|
|
return "https://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
|
name: "OSM",
|
|
|
|
|
alt : "Open Street Map",
|
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2012-06-21 13:29:17 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.mapTypes.set("OSM2", new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function(coord, zoom) {
|
2017-03-01 09:12:32 +00:00
|
|
|
|
if (hasThunderforestApiKey)
|
2017-06-22 07:27:49 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/cycle/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2017-03-01 09:12:32 +00:00
|
|
|
|
else
|
|
|
|
|
return "http://a.tile.opencyclemap.org/cycle/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
|
name: "OCM",
|
|
|
|
|
alt : "Open Cycle Map",
|
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2012-06-21 13:29:17 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.mapTypes.set("OSM4", new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function(coord, zoom) {
|
2017-03-01 09:12:32 +00:00
|
|
|
|
if (hasThunderforestApiKey)
|
2017-06-22 07:27:49 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/transport/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2017-03-01 09:12:32 +00:00
|
|
|
|
else
|
|
|
|
|
return "http://a.tile2.opencyclemap.org/transport/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
|
name: "OCM-Tran",
|
|
|
|
|
alt : "Open Cycle Map - Transport",
|
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.mapTypes.set("OSM5", new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function(coord, zoom) {
|
2017-03-01 09:12:32 +00:00
|
|
|
|
if (hasThunderforestApiKey)
|
2017-06-22 07:27:49 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/landscape/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2017-03-01 09:12:32 +00:00
|
|
|
|
else
|
|
|
|
|
return "http://a.tile3.opencyclemap.org/landscape/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
|
name: "OCM-Land",
|
|
|
|
|
alt : "Open Cycle Map - Landscape",
|
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.mapTypes.set("OSM6", new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function(coord, zoom) {
|
2017-06-22 07:27:49 +00:00
|
|
|
|
return "https://tile2.maptoolkit.net/terrain/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
|
|
|
|
name: "MTK-Terr",
|
|
|
|
|
alt : "MapToolKit - Terrain",
|
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2014-06-09 13:18:24 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// FULL SCREEN BUTTON
|
|
|
|
|
var controlDiv = document.createElement('div');
|
|
|
|
|
controlDiv.style.padding = '5px';
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2012-10-30 14:03:16 +00:00
|
|
|
|
// Set CSS for the control border
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var controlUI = document.createElement('img');
|
|
|
|
|
controlUI.src = pluginUrl + "/wp-gpx-maps/img/goFullScreen.png";
|
|
|
|
|
controlUI.style.cursor = 'pointer';
|
|
|
|
|
controlUI.title = lng.goFullScreen;
|
|
|
|
|
controlDiv.appendChild(controlUI);
|
2012-10-30 14:03:16 +00:00
|
|
|
|
|
|
|
|
|
// Setup the click event listeners
|
2014-03-14 13:38:36 +00:00
|
|
|
|
google.maps.event.addDomListener(controlUI, 'click', function(event) {
|
|
|
|
|
var isFullScreen = (controlUI.isfullscreen == true);
|
2014-06-09 13:18:24 +00:00
|
|
|
|
var mapDiv = [ map.getDiv(), map.getDiv().parentNode ];
|
2012-10-30 14:03:16 +00:00
|
|
|
|
var center = map.getCenter();
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (isFullScreen)
|
2012-10-30 14:03:16 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.setOptions( { scrollwheel : (zoomOnScrollWheel == 'true') } );
|
|
|
|
|
jQuery(mapDiv).css("position", 'relative').
|
|
|
|
|
css('top', 0).
|
|
|
|
|
css("width", controlUI.googleMapWidth).
|
|
|
|
|
css("height", controlUI.googleMapHeight).
|
|
|
|
|
css("z-index", '');
|
|
|
|
|
google.maps.event.trigger(map, 'resize');
|
|
|
|
|
map.setCenter(center);
|
|
|
|
|
controlUI.src = pluginUrl + "/wp-gpx-maps/img/goFullScreen.png";
|
|
|
|
|
controlUI.title = lng.gofullscreen;
|
2012-10-30 14:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.setOptions( { scrollwheel : true } );
|
|
|
|
|
controlUI.googleMapWidth = jQuery(mapDiv).css('width');
|
|
|
|
|
controlUI.googleMapHeight = jQuery(mapDiv).css('height');
|
|
|
|
|
jQuery(mapDiv).css("position", 'fixed').
|
|
|
|
|
css('top', 0).
|
|
|
|
|
css('left', 0).
|
|
|
|
|
css("width", '100%').
|
|
|
|
|
css("height", '100%').
|
2014-05-05 07:45:44 +00:00
|
|
|
|
css("z-index", '100');
|
2014-03-14 13:38:36 +00:00
|
|
|
|
jQuery("#wpadminbar").each(function(){
|
|
|
|
|
jQuery(mapDiv).css('top', jQuery(this).height());
|
|
|
|
|
});
|
|
|
|
|
google.maps.event.trigger(map, 'resize');
|
|
|
|
|
map.setCenter(center);
|
|
|
|
|
controlUI.src = pluginUrl + "/wp-gpx-maps/img/exitFullFcreen.png";
|
|
|
|
|
controlUI.title = lng.exitFullFcreen;
|
2012-10-30 14:03:16 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
controlUI.isfullscreen = !isFullScreen;
|
2012-10-30 14:03:16 +00:00
|
|
|
|
return false;
|
|
|
|
|
});
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2012-02-15 16:04:18 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
controlDiv.index = 1;
|
|
|
|
|
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(controlDiv);
|
|
|
|
|
|
|
|
|
|
var bounds = new google.maps.LatLngBounds();
|
|
|
|
|
|
|
|
|
|
var markerCurrentPosition = null;
|
|
|
|
|
|
|
|
|
|
if ( usegpsposition == "true" )
|
2012-03-05 07:57:36 +00:00
|
|
|
|
{
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Try HTML5 geolocation
|
|
|
|
|
if(navigator.geolocation) {
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
navigator.geolocation.getCurrentPosition(function(position) {
|
|
|
|
|
|
|
|
|
|
// user position
|
|
|
|
|
var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
|
|
|
|
|
|
|
|
|
|
// draw current position marker
|
|
|
|
|
markerCurrentPosition = new google.maps.Marker({
|
|
|
|
|
position: pos,
|
|
|
|
|
map: map,
|
|
|
|
|
title: "you",
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (currentpositioncon)
|
|
|
|
|
{
|
|
|
|
|
markerCurrentPosition.setIcon(currentpositioncon);
|
|
|
|
|
}
|
|
|
|
|
bounds.extend(pos);
|
|
|
|
|
|
|
|
|
|
map.setCenter(bounds.getCenter());
|
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, function() {});
|
|
|
|
|
|
|
|
|
|
navigator.geolocation.watchPosition(function(position){
|
|
|
|
|
// move current position marker
|
|
|
|
|
if (markerCurrentPosition != null)
|
|
|
|
|
{
|
|
|
|
|
markerCurrentPosition.setPosition(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(e){
|
|
|
|
|
// some errors
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
enableHighAccuracy: false,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
maximumAge: 0
|
|
|
|
|
});
|
|
|
|
|
}
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
|
|
|
|
}
|
2011-12-24 14:37:05 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
// Print WayPoints
|
2015-12-15 09:46:08 +00:00
|
|
|
|
if (!jQuery.isEmptyObject(waypoints))
|
2012-03-05 07:57:36 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2017-06-22 07:27:49 +00:00
|
|
|
|
var image = new google.maps.MarkerImage('https://maps.google.com/mapfiles/ms/micons/flag.png',
|
2014-03-14 13:38:36 +00:00
|
|
|
|
new google.maps.Size(32, 32),
|
|
|
|
|
new google.maps.Point(0,0),
|
|
|
|
|
new google.maps.Point(16, 32)
|
|
|
|
|
);
|
2017-06-22 07:27:49 +00:00
|
|
|
|
var shadow = new google.maps.MarkerImage('https://maps.google.com/mapfiles/ms/micons/flag.shadow.png',
|
2014-03-14 13:38:36 +00:00
|
|
|
|
new google.maps.Size(59, 32),
|
|
|
|
|
new google.maps.Point(0,0),
|
|
|
|
|
new google.maps.Point(16, 32)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (waypointIcon!='')
|
|
|
|
|
{
|
|
|
|
|
image = new google.maps.MarkerImage(waypointIcon);
|
|
|
|
|
shadow = '';
|
2015-12-15 09:46:08 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2015-12-15 09:46:08 +00:00
|
|
|
|
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);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
bounds.extend(new google.maps.LatLng(lat, lon));
|
2015-12-15 09:46:08 +00:00
|
|
|
|
|
|
|
|
|
});
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Print Images
|
2011-12-29 09:54:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
jQuery("#ngimages_" + targetId).attr("style","display:block;position:absolute;left:-50000px");
|
|
|
|
|
jQuery("#ngimages_" + targetId + " span").each(function(){
|
2011-12-29 09:54:00 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var imageLat = jQuery(this).attr("lat");
|
|
|
|
|
var imageLon = jQuery(this).attr("lon");
|
|
|
|
|
|
|
|
|
|
jQuery("img",this).each(function() {
|
|
|
|
|
|
|
|
|
|
jQuery(this).load(function(){
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var imageUrl = jQuery(this).attr("src");
|
|
|
|
|
var img_w = jQuery(this).width();
|
|
|
|
|
var img_h = jQuery(this).height();
|
|
|
|
|
|
|
|
|
|
imageLat = imageLat.replace(",", ".");
|
|
|
|
|
imageLon = imageLon.replace(",", ".");
|
|
|
|
|
|
|
|
|
|
var p = new google.maps.LatLng(imageLat, imageLon);
|
|
|
|
|
bounds.extend(p);
|
|
|
|
|
|
|
|
|
|
var mc = new CustomMarker(map, p, imageUrl, img_w, img_h );
|
|
|
|
|
|
|
|
|
|
ngImageMarkers.push(mc);
|
|
|
|
|
|
|
|
|
|
google.maps.event.addListener(mc, "click", function(div) {
|
|
|
|
|
var lat = div.getAttribute("lat");
|
|
|
|
|
var lon = div.getAttribute("lon");
|
|
|
|
|
var a = getClosestImage(lat,lon,targetId).childNodes[0];
|
|
|
|
|
if (a)
|
2012-07-02 12:51:45 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
a.click();
|
2012-07-02 12:51:45 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (jQuery(this).width() + jQuery(this).height() > 0)
|
|
|
|
|
{
|
|
|
|
|
jQuery(this).trigger("load");
|
2011-12-29 09:54:00 +00:00
|
|
|
|
}
|
2012-10-30 14:03:16 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
// Nextgen Pro Lightbox FIX
|
|
|
|
|
var _xx = jQuery("#ngimages_" + targetId + " .nextgen_pro_lightbox");
|
|
|
|
|
if (_xx.length > 0)
|
2012-10-30 14:03:16 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
var rnd1 = Math.random().toString(36).substring(7);
|
|
|
|
|
var rnd2 = Math.random().toString(36).substring(7);
|
|
|
|
|
|
|
|
|
|
//get first gallery without images
|
|
|
|
|
for (var _temp in galleries) {
|
|
|
|
|
var _gal = galleries[_temp];
|
|
|
|
|
|
|
|
|
|
if (_gal.source == "random_images" && _gal.wpgpxmaps != true )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_gal.source == "galleries";
|
|
|
|
|
_gal.wpgpxmaps = true;
|
|
|
|
|
_transient_id = _temp.replace("gallery_","")
|
|
|
|
|
_gal["entity_ids"] = [];
|
|
|
|
|
_gal["image_ids"] = [];
|
|
|
|
|
_gal["gallery_ids"] = [96];
|
|
|
|
|
for (var i=0;i<_xx.length;i++)
|
|
|
|
|
{
|
|
|
|
|
var __xx = jQuery(_xx[i]);
|
|
|
|
|
__xx.attr("data-nplmodal-gallery-id", _transient_id);
|
|
|
|
|
_gal["image_ids"].push(__xx.attr("data-image-id"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-30 14:03:16 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ( jQuery("#ngimages_" + targetId + " span").length > 0 )
|
2012-10-30 14:03:16 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2012-10-30 14:03:16 +00:00
|
|
|
|
// Set CSS for the control border
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var controlUIhi = document.createElement('img');
|
|
|
|
|
controlUIhi.src = pluginUrl + "/wp-gpx-maps/img/hideImages.png";
|
|
|
|
|
controlUIhi.style.cursor = 'pointer';
|
|
|
|
|
controlUIhi.title = lng.hideImages;
|
|
|
|
|
controlDiv.appendChild(controlUIhi);
|
2012-10-30 14:03:16 +00:00
|
|
|
|
|
|
|
|
|
// Setup the click event listeners
|
2014-03-14 13:38:36 +00:00
|
|
|
|
google.maps.event.addDomListener(controlUIhi, 'click', function(event) {
|
|
|
|
|
var isImagesHidden = (controlUIhi.isImagesHidden == true);
|
|
|
|
|
var mapDiv = map.getDiv();
|
|
|
|
|
var center = map.getCenter();
|
|
|
|
|
|
|
|
|
|
if (isImagesHidden)
|
|
|
|
|
{
|
|
|
|
|
for (var i=0; i<ngImageMarkers.length; i++) {
|
|
|
|
|
ngImageMarkers[i].setMap(map);
|
|
|
|
|
}
|
|
|
|
|
controlUIhi.src = pluginUrl + "/wp-gpx-maps/img/hideImages.png";
|
|
|
|
|
controlUIhi.title = lng.hideImages;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (var i=0; i<ngImageMarkers.length; i++) {
|
|
|
|
|
ngImageMarkers[i].setMap(null);
|
|
|
|
|
}
|
|
|
|
|
controlUIhi.src = pluginUrl + "/wp-gpx-maps/img/showImages.png";
|
|
|
|
|
controlUIhi.title = lng.showImages;
|
|
|
|
|
}
|
|
|
|
|
controlUIhi.isImagesHidden = !isImagesHidden;
|
2012-10-30 14:03:16 +00:00
|
|
|
|
return false;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
});
|
2012-06-13 13:14:18 +00:00
|
|
|
|
|
2012-02-22 14:29:44 +00:00
|
|
|
|
}
|
2012-02-15 16:04:18 +00:00
|
|
|
|
|
2012-06-27 13:48:34 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Print Track
|
|
|
|
|
if (mapData != '')
|
|
|
|
|
{
|
|
|
|
|
var points = [];
|
|
|
|
|
var lastCut=0;
|
|
|
|
|
var polylinenes = [];
|
|
|
|
|
var polyline_number=0;
|
|
|
|
|
var color=0;
|
|
|
|
|
for (i=0; i < mapData.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (mapData[i] == null)
|
|
|
|
|
{
|
|
|
|
|
|
2013-05-16 11:54:44 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
color=color1[polyline_number % color1.length];
|
2013-07-05 12:43:58 +00:00
|
|
|
|
|
2013-05-16 11:54:44 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var poly = new google.maps.Polyline({
|
|
|
|
|
path: points.slice(lastCut,i),
|
|
|
|
|
strokeColor: color,
|
|
|
|
|
strokeOpacity: .7,
|
|
|
|
|
strokeWeight: 4,
|
|
|
|
|
map: map
|
|
|
|
|
});
|
|
|
|
|
polylinenes.push(poly);
|
|
|
|
|
lastCut=i;
|
|
|
|
|
polyline_number= polyline_number +1;
|
|
|
|
|
//var p = new google.maps.LatLng(mapData[i-1][0], mapData[i-1][1]);
|
|
|
|
|
//points.push(p);
|
|
|
|
|
//bounds.extend(p);
|
2012-04-07 09:11:37 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var p = new google.maps.LatLng(mapData[i][0], mapData[i][1]);
|
|
|
|
|
points.push(p);
|
|
|
|
|
bounds.extend(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (points.length != lastCut)
|
|
|
|
|
{
|
|
|
|
|
if ( polyline_number < color1.length)
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
color=color1[polyline_number];
|
2012-04-07 09:11:37 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
else
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
color=color1[color1.length-1];
|
2012-04-07 09:11:37 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var poly = new google.maps.Polyline({
|
|
|
|
|
path: points.slice(lastCut),
|
|
|
|
|
strokeColor: color,
|
|
|
|
|
strokeOpacity: .7,
|
|
|
|
|
strokeWeight: 4,
|
|
|
|
|
map: map
|
|
|
|
|
});
|
|
|
|
|
polylinenes.push(poly);
|
|
|
|
|
currentPoints = [];
|
|
|
|
|
polyline_number= polyline_number +1;
|
|
|
|
|
}
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (startIcon != '')
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var startIconImage = new google.maps.MarkerImage(startIcon);
|
|
|
|
|
var startMarker = new google.maps.Marker({
|
|
|
|
|
position: points[0],
|
|
|
|
|
map: map,
|
|
|
|
|
title: "Start",
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
icon: startIconImage,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2012-04-07 09:11:37 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
if (endIcon != '')
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var endIconImage = new google.maps.MarkerImage(endIcon);
|
|
|
|
|
var startMarker = new google.maps.Marker({
|
|
|
|
|
position: points[ points.length -1 ],
|
|
|
|
|
map: map,
|
|
|
|
|
title: "Start",
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
icon: endIconImage,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
|
|
|
|
|
2012-08-06 09:54:48 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
var first = getItemFromArray(mapData,0)
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (currentIcon == '')
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2017-06-22 07:27:49 +00:00
|
|
|
|
currentIcon = "https://maps.google.com/mapfiles/kml/pal4/icon25.png";
|
2012-04-07 09:11:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var current = new google.maps.MarkerImage(currentIcon,
|
|
|
|
|
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: current,
|
|
|
|
|
map: map,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (i=0; i < polylinenes.length; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
google.maps.event.addListener(polylinenes[i],'mouseover',function(event){
|
|
|
|
|
if (marker)
|
|
|
|
|
{
|
|
|
|
|
marker.setPosition(event.latLng);
|
|
|
|
|
marker.setTitle(lng.currentPosition);
|
2018-03-09 09:02:25 +00:00
|
|
|
|
if (myChart)
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
var l1 = event.latLng.lat();
|
|
|
|
|
var l2 = event.latLng.lng();
|
|
|
|
|
var ci = getClosestIndex(mapData,l1,l2);
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var activeElements = [];
|
|
|
|
|
var seriesLen = myChart.data.datasets.length;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
for(var i=0; i<seriesLen;i++)
|
|
|
|
|
{
|
2018-03-09 09:02:25 +00:00
|
|
|
|
activeElements.push(myChart.chart.getDatasetMeta(i).data[ci]);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
if (activeElements.length > 0)
|
|
|
|
|
{
|
|
|
|
|
myChart.options.customLine.x = activeElements[0]._model.x;
|
|
|
|
|
if (isNaN(myChart.tooltip._eventPosition))
|
|
|
|
|
{
|
|
|
|
|
myChart.tooltip._eventPosition = {
|
|
|
|
|
x: activeElements[0]._model.x,
|
|
|
|
|
y: activeElements[0]._model.y
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
myChart.tooltip._active = activeElements;
|
|
|
|
|
myChart.tooltip.update(true);
|
|
|
|
|
myChart.draw();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.setCenter(bounds.getCenter());
|
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
|
|
2014-06-09 13:18:24 +00:00
|
|
|
|
// FIX post tabs
|
|
|
|
|
var $_tab = $(el).closest(".wordpress-post-tabs").eq(0);
|
|
|
|
|
if ($_tab)
|
|
|
|
|
{
|
2014-07-14 07:48:30 +00:00
|
|
|
|
$("div > ul > li > a", $_tab).click(function(e){
|
|
|
|
|
setTimeout(function(e){
|
2014-06-09 13:18:24 +00:00
|
|
|
|
google.maps.event.trigger(map, 'resize');
|
2014-07-14 07:48:30 +00:00
|
|
|
|
//map.setCenter(bounds.getCenter());
|
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
|
tabResized = true;
|
2014-06-09 13:18:24 +00:00
|
|
|
|
},10);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var controlUIcenter = null;
|
|
|
|
|
var idFirstCenterChanged = true;
|
|
|
|
|
|
|
|
|
|
google.maps.event.addListener(map, 'center_changed', function() {
|
|
|
|
|
|
|
|
|
|
if (idFirstCenterChanged == true)
|
|
|
|
|
{
|
|
|
|
|
idFirstCenterChanged = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (controlUIcenter == null)
|
|
|
|
|
{
|
|
|
|
|
// Set CSS for the control border
|
|
|
|
|
controlUIcenter = document.createElement('img');
|
|
|
|
|
controlUIcenter.src = pluginUrl + "/wp-gpx-maps/img/backToCenter.png";
|
|
|
|
|
controlUIcenter.style.cursor = 'pointer';
|
|
|
|
|
controlUIcenter.title = lng.backToCenter;
|
|
|
|
|
controlDiv.appendChild(controlUIcenter);
|
|
|
|
|
|
|
|
|
|
// Setup the click event listeners
|
|
|
|
|
google.maps.event.addDomListener(controlUIcenter, 'click', function(event) {
|
|
|
|
|
map.setCenter(bounds.getCenter());
|
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
|
controlDiv.removeChild(controlUIcenter);
|
|
|
|
|
controlUIcenter = null;
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var graphh = jQuery('#myChart_' + params.targetId).css("height");
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
if (graphDist != '' && (graphEle != '' || graphSpeed != '' || graphHr != '' || graphAtemp != '' || graphCad != '') && graphh != "0px")
|
2012-02-15 16:04:18 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
var valLen = graphDist.length;
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (unit=="1")
|
2012-12-21 13:46:55 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
l_x = { suf : "mi", dec : 1 };
|
|
|
|
|
l_y = { suf : "ft", dec : 0 };
|
|
|
|
|
}
|
|
|
|
|
else if (unit=="2")
|
2012-06-25 10:22:56 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
l_x = { suf : "km", dec : 1 };
|
|
|
|
|
l_y = { suf : "m", dec : 0 };
|
|
|
|
|
}
|
|
|
|
|
else if (unit=="3")
|
2012-02-15 16:04:18 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
l_x = { suf : "NM", dec : 1 };
|
|
|
|
|
l_y = { suf : "m", dec : 0 };
|
|
|
|
|
}
|
|
|
|
|
else if (unit=="4")
|
2012-02-15 16:04:18 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
l_x = { suf : "mi", dec : 1 };
|
|
|
|
|
l_y = { suf : "m", dec : 0 };
|
|
|
|
|
}
|
2014-06-09 13:18:24 +00:00
|
|
|
|
else if (unit=="5")
|
|
|
|
|
{
|
|
|
|
|
l_x = { suf : "NM", dec : 1 };
|
|
|
|
|
l_y = { suf : "ft", dec : 0 };
|
|
|
|
|
}
|
2012-02-15 16:04:18 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
l_x = { suf : "m", dec : 0 };
|
|
|
|
|
l_y = { suf : "m", dec : 0 };
|
2012-02-15 16:04:18 +00:00
|
|
|
|
}
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var nn = 1111.1;
|
|
|
|
|
var _nn = nn.toLocaleString();
|
|
|
|
|
var _nnLen = _nn.length;
|
|
|
|
|
var decPoint = _nn.substring(_nnLen - 2, _nnLen - 1);
|
|
|
|
|
var thousandsSep = _nn.substring(1, 2);
|
|
|
|
|
|
|
|
|
|
if (decPoint == "1")
|
|
|
|
|
decPoint = ".";
|
|
|
|
|
|
|
|
|
|
if (thousandsSep == "1")
|
|
|
|
|
thousandsSep = "";
|
|
|
|
|
|
|
|
|
|
// define the options
|
|
|
|
|
var hoptions = {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
type: 'line',
|
|
|
|
|
data: {
|
|
|
|
|
datasets: [],
|
|
|
|
|
},
|
2018-04-04 06:45:39 +00:00
|
|
|
|
borderWidth: 1,
|
2018-03-09 09:02:25 +00:00
|
|
|
|
options: {
|
2018-03-13 08:19:37 +00:00
|
|
|
|
animation: {
|
|
|
|
|
//duration: 0, // general animation time
|
|
|
|
|
},
|
|
|
|
|
hover: {
|
|
|
|
|
//animationDuration: 0, // duration of animations when hovering an item
|
|
|
|
|
},
|
|
|
|
|
//responsiveAnimationDuration: 0, // animation duration after a resize
|
2018-03-09 09:02:25 +00:00
|
|
|
|
customLine: {
|
|
|
|
|
color: 'gray'
|
|
|
|
|
},
|
|
|
|
|
scales: {
|
|
|
|
|
yAxes: [],
|
|
|
|
|
xAxes: [{
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
suggestedMin: 0,
|
|
|
|
|
max: graphDist[graphDist.length-1],
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
2018-03-16 22:08:58 +00:00
|
|
|
|
return Math.round(value, l_x.dec) + l_x.suf;
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
},
|
|
|
|
|
tooltips: {
|
2018-03-13 08:19:37 +00:00
|
|
|
|
position: 'average',
|
2018-03-09 09:02:25 +00:00
|
|
|
|
mode: 'index',
|
2018-03-13 08:19:37 +00:00
|
|
|
|
intersect: false,
|
2018-03-09 09:02:25 +00:00
|
|
|
|
callbacks : {
|
|
|
|
|
title: function(tooltipItems, data) {
|
|
|
|
|
//Return value for title
|
|
|
|
|
var fpt = _formats[0];
|
|
|
|
|
return Math.round(tooltipItems[0].xLabel, fpt.dec) + fpt.suf;;
|
|
|
|
|
},
|
|
|
|
|
label : function(tooltipItem, data) {
|
|
|
|
|
// format list values
|
|
|
|
|
var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
|
|
var fpt = _formats[tooltipItem.datasetIndex];
|
|
|
|
|
if (label) {
|
|
|
|
|
label += ': ';
|
|
|
|
|
}
|
|
|
|
|
label += Math.round(tooltipItem.yLabel, fpt.dec) + fpt.suf;
|
|
|
|
|
return label;
|
|
|
|
|
},
|
|
|
|
|
footer : function(tooltipItem){
|
|
|
|
|
// move the point in map
|
|
|
|
|
var i = tooltipItem[0].index;
|
|
|
|
|
if (marker)
|
|
|
|
|
{
|
|
|
|
|
var point = getItemFromArray(mapData,i)
|
|
|
|
|
if (point)
|
|
|
|
|
{
|
|
|
|
|
marker.setPosition(new google.maps.LatLng(point[0],point[1]));
|
|
|
|
|
}
|
|
|
|
|
marker.setTitle(lng.currentPosition);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
plugins: [{
|
|
|
|
|
beforeEvent: function(chart, e) {
|
|
|
|
|
if ((e.type === 'mousemove')
|
|
|
|
|
&& (e.x >= e.chart.chartArea.left)
|
|
|
|
|
&& (e.x <= e.chart.chartArea.right)
|
|
|
|
|
) {
|
|
|
|
|
chart.options.customLine.x = e.x;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
afterDraw: function(chart, easing) {
|
|
|
|
|
var ctx = chart.chart.ctx;
|
|
|
|
|
var chartArea = chart.chartArea;
|
|
|
|
|
var x = chart.options.customLine.x;
|
|
|
|
|
if (!isNaN(x)) {
|
|
|
|
|
ctx.save();
|
|
|
|
|
ctx.strokeStyle = chart.options.customLine.color;
|
|
|
|
|
ctx.moveTo(chart.options.customLine.x, chartArea.bottom);
|
|
|
|
|
ctx.lineTo(chart.options.customLine.x, chartArea.top);
|
|
|
|
|
ctx.stroke();
|
|
|
|
|
ctx.restore();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
labels : graphDist,
|
|
|
|
|
|
|
|
|
|
oldchart: {
|
|
|
|
|
renderTo: 'myChart_' + params.targetId,
|
2014-03-14 13:38:36 +00:00
|
|
|
|
type: 'area',
|
|
|
|
|
events: {
|
|
|
|
|
selection: function(event) {
|
|
|
|
|
|
|
|
|
|
if (event.xAxis) {
|
|
|
|
|
|
|
|
|
|
el_report.innerHTML = 'Zoom: '+ (event.xAxis[0].min).toFixed(l_x.dec) + ' ' + l_x.suf + ' -> '+ (event.xAxis[0].max).toFixed(decPoint) + ' ' + l_x.suf + '<br />';
|
|
|
|
|
|
|
|
|
|
var seriesLength = event.currentTarget.series.length;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < seriesLength; i++) {
|
|
|
|
|
|
|
|
|
|
var dataX = {value: 0, count: 0};
|
|
|
|
|
|
|
|
|
|
var serie = event.currentTarget.series[i];
|
|
|
|
|
var points = serie.points;
|
|
|
|
|
var min = event.xAxis[0].min, max = event.xAxis[0].max;
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < points.length; j++) {
|
|
|
|
|
if (points[j].x >= min && points[j].x <= max) {
|
|
|
|
|
dataX.value += points[j].y;
|
|
|
|
|
dataX.count +=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var name = serie.name;
|
|
|
|
|
|
|
|
|
|
if (name == lng.altitude) {
|
|
|
|
|
el_report.innerHTML += name + ' avg: ' + (dataX.value / dataX.count).toFixed(l_y.dec) + " " + l_y.suf + "<br />";
|
|
|
|
|
} else if (name == lng.speed) {
|
|
|
|
|
el_report.innerHTML += name + ' avg: ' + (dataX.value / dataX.count).toFixed(l_s.dec) + " " + l_s.suf + "<br />";
|
|
|
|
|
} else if (name == lng.grade) {
|
|
|
|
|
el_report.innerHTML += name + ' avg: ' + (dataX.value / dataX.count).toFixed(l_grade.dec) + " " + l_grade.suf + "<br />";
|
|
|
|
|
} else if (name == lng.cadence) {
|
|
|
|
|
el_report.innerHTML += name + ' avg: ' + (dataX.value / dataX.count).toFixed(l_cad.dec) + " " + l_cad.suf + "<br />";
|
|
|
|
|
} else if (name == lng.heartRate) {
|
|
|
|
|
el_report.innerHTML += name + ' avg: ' + (dataX.value / dataX.count).toFixed(l_hr.dec) + " " + l_hr.suf + "<br />";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
el_report.innerHTML += serie.name + ' avg: ' + dataX.value / dataX.count + "<br />";
|
|
|
|
|
}
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
el_report.innerHTML += "<br />"
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
el_report.innerHTML = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
zoomType: 'x'
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (graphEle != '')
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphEle);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var yaxe = {
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, l_y.dec) + l_y.suf;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
},
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
if ( chartFrom1 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.min = chartFrom1;
|
|
|
|
|
yaxe.startOnTick = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
yaxe.min = myData.Min;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( chartTo1 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.max = chartTo1;
|
|
|
|
|
yaxe.endOnTick = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
yaxe.max = myData.Max;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_y)
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.altitude, myData.Items, color2, yaxe.id ));
|
2018-03-09 09:02:25 +00:00
|
|
|
|
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
if (graphSpeed != '') {
|
|
|
|
|
if (unitspeed == '6') /* min/100m */
|
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "min/100m", dec : 2 };
|
|
|
|
|
}
|
2017-02-27 08:47:04 +00:00
|
|
|
|
else if (unitspeed == '5') /* knots */
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "knots", dec : 2 };
|
|
|
|
|
}
|
2017-02-27 08:47:04 +00:00
|
|
|
|
else if (unitspeed == '4') /* min/miles */
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "min/mi", dec : 2 };
|
|
|
|
|
}
|
2017-02-27 08:47:04 +00:00
|
|
|
|
else if (unitspeed == '3') /* min/km */
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "min/km", dec : 2 };
|
|
|
|
|
}
|
2017-02-27 08:47:04 +00:00
|
|
|
|
else if (unitspeed == '2') /* miles/h */
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "mi/h", dec : 0 };
|
|
|
|
|
}
|
2017-02-27 08:47:04 +00:00
|
|
|
|
else if (unitspeed == '1') /* km/h */
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "km/h", dec : 0 };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "m/s", dec : 0 };
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphSpeed);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
var yaxe = {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, l_s.dec) + l_s.suf;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2018-03-09 09:02:25 +00:00
|
|
|
|
position: 'right',
|
|
|
|
|
scalePositionLeft: false,
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
if ( chartFrom2 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.min = chartFrom2;
|
|
|
|
|
yaxe.startOnTick = false;
|
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
else {
|
|
|
|
|
yaxe.min = myData.Min;
|
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
if ( chartTo2 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.max = chartTo2;
|
|
|
|
|
yaxe.endOnTick = false;
|
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
else {
|
|
|
|
|
yaxe.max = myData.Max;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_s);
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.speed, myData.Items, color3, yaxe.id ) );
|
2018-03-09 09:02:25 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphHr != '')
|
2011-12-14 10:35:25 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphHr);
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var yaxe = {
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, l_hr.dec) + l_hr.suf;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2018-03-09 09:02:25 +00:00
|
|
|
|
position: 'right',
|
|
|
|
|
scalePositionLeft: false,
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
2013-05-16 11:54:44 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.heartRate, myData.Items, color4, yaxe.id ) );
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_hr);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphAtemp != '')
|
2012-04-12 14:49:22 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphAtemp);
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var yaxe = {
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, 1) + "°C";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2018-03-09 09:02:25 +00:00
|
|
|
|
position: 'right',
|
|
|
|
|
scalePositionLeft: false,
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.atemp, myData,Items, color7, yaxe.id ) );
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push({ suf : "°C", dec : 1 });
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphCad != '')
|
2013-02-04 08:58:18 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphCad, true);
|
|
|
|
|
|
|
|
|
|
var yaxe = {
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, l_cad.dec) + l_cad.suf;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2018-03-09 09:02:25 +00:00
|
|
|
|
position: 'right',
|
|
|
|
|
scalePositionLeft: false,
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.cadence, myData.Items, color5, yaxe.id) );
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_cad);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphGrade != '')
|
|
|
|
|
{
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphGrade);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var yaxe = {
|
|
|
|
|
type: 'linear',
|
|
|
|
|
ticks: {
|
|
|
|
|
// Include a dollar sign in the ticks
|
|
|
|
|
callback: function(value, index, values) {
|
|
|
|
|
return Math.round(value, l_grade.dec) + l_grade.suf;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2018-03-09 09:02:25 +00:00
|
|
|
|
position: 'right',
|
|
|
|
|
scalePositionLeft: false,
|
|
|
|
|
id: "y-axis-" + (hoptions.options.scales.yAxes.length + 1),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_formats.push(l_grade);
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2018-04-04 06:45:39 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.grade, myData.Items, color6, yaxe.id ) );
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
|
|
|
|
|
var ctx = document.getElementById("myChart_" + params.targetId).getContext('2d');
|
|
|
|
|
|
|
|
|
|
var myChart = new Chart(ctx, hoptions);
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
jQuery("#myChart_" + params.targetId).css("display","none");
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
return this;
|
|
|
|
|
};
|
2012-04-07 09:11:37 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
function mergeArrayForChart(distArr, dataArr, setZerosAsNull)
|
|
|
|
|
{
|
|
|
|
|
var l = distArr.length;
|
|
|
|
|
|
|
|
|
|
var items = new Array(l);
|
|
|
|
|
var min=10000;
|
|
|
|
|
var max=-10000;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<l; i++)
|
|
|
|
|
{
|
|
|
|
|
if (distArr[i] != null)
|
|
|
|
|
{
|
|
|
|
|
var _item = dataArr[i];
|
|
|
|
|
|
|
|
|
|
if (setZerosAsNull === true && _item === 0)
|
|
|
|
|
{
|
|
|
|
|
_item = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items[i] = {
|
|
|
|
|
x: distArr[i],
|
|
|
|
|
y:_item
|
|
|
|
|
};
|
|
|
|
|
if (_item > max)
|
|
|
|
|
max = _item;
|
|
|
|
|
if (_item < min)
|
|
|
|
|
min = _item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
Items : items,
|
|
|
|
|
Min : min,
|
|
|
|
|
Max : max,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 06:45:39 +00:00
|
|
|
|
function wpgpxmapsGetDataset(name,data,color, id) {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
return {
|
|
|
|
|
label: name,
|
|
|
|
|
data : data,
|
|
|
|
|
borderColor: color,
|
|
|
|
|
backgroundColor: hexToRgbA(color, .3),
|
|
|
|
|
pointRadius: 0,
|
2018-04-04 06:45:39 +00:00
|
|
|
|
borderWidth: 1,
|
2018-03-09 09:02:25 +00:00
|
|
|
|
pointHoverRadius: 1,
|
|
|
|
|
yAxisID: id,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hexToRgbA(hex,a){
|
|
|
|
|
var c;
|
|
|
|
|
if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
|
|
|
|
|
c= hex.substring(1).split('');
|
|
|
|
|
if(c.length== 3){
|
|
|
|
|
c= [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
|
|
|
}
|
|
|
|
|
c= '0x'+c.join('');
|
|
|
|
|
return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',' + a +')';
|
|
|
|
|
}
|
|
|
|
|
throw new Error('Bad Hex');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
function addWayPoint(map, image, shadow, lat, lon, title, descr)
|
|
|
|
|
{
|
|
|
|
|
var p = new google.maps.LatLng(lat, lon);
|
|
|
|
|
var m = new google.maps.Marker({
|
|
|
|
|
position: p,
|
|
|
|
|
map: map,
|
|
|
|
|
title: title,
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
shadow: shadow,
|
|
|
|
|
icon: image,
|
|
|
|
|
zIndex: 5
|
|
|
|
|
});
|
|
|
|
|
|
2015-12-15 09:46:08 +00:00
|
|
|
|
google.maps.event.addListener(m, 'click', function() {
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (infowindow)
|
|
|
|
|
{
|
|
|
|
|
infowindow.close();
|
|
|
|
|
}
|
|
|
|
|
var cnt = '';
|
2015-12-15 09:46:08 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (title=='')
|
|
|
|
|
{
|
2015-12-15 09:46:08 +00:00
|
|
|
|
cnt = "<div>" + unescape(descr) + "</div>";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-15 09:46:08 +00:00
|
|
|
|
cnt = "<div><b>" + title + "</b><br />" + unescape(descr) + "</div>";
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2015-12-15 09:46:08 +00:00
|
|
|
|
|
|
|
|
|
cnt += "<br /><p><a href='https://maps.google.com?daddr=" + lat + "," + lon + "' target='_blank'>Itinéraire</a></p>";
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
infowindow = new google.maps.InfoWindow({ content: cnt});
|
|
|
|
|
infowindow.open(map,m);
|
|
|
|
|
});
|
2015-12-15 09:46:08 +00:00
|
|
|
|
/*
|
2014-07-09 15:55:55 +00:00
|
|
|
|
google.maps.event.addListener(m, "mouseout", function () {
|
|
|
|
|
if (infowindow)
|
|
|
|
|
{
|
|
|
|
|
infowindow.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-12-15 09:46:08 +00:00
|
|
|
|
*/
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2011-12-24 14:37:05 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
function getItemFromArray(arr,index)
|
|
|
|
|
{
|
|
|
|
|
try
|
2012-03-17 11:46:00 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
return arr[index];
|
2012-03-17 11:46:00 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
catch(e)
|
2012-03-17 11:46:00 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
return [0,0];
|
2012-03-17 11:46:00 +00:00
|
|
|
|
}
|
2011-12-14 10:35:25 +00:00
|
|
|
|
}
|
2011-12-29 09:54:00 +00:00
|
|
|
|
|
2012-09-12 13:59:14 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
function getClosestIndex(points,lat,lon)
|
2011-12-29 09:54:00 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var dd=10000;
|
|
|
|
|
var ii=0;
|
|
|
|
|
for (i=0; i < points.length; i++)
|
2011-12-29 09:54:00 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (points[i]==null)
|
|
|
|
|
continue;
|
|
|
|
|
|
2018-04-04 06:45:39 +00:00
|
|
|
|
var d = wpgpxmapsDist(points[i][0], points[i][1], lat, lon);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( d < dd )
|
|
|
|
|
{
|
|
|
|
|
ii = i;
|
|
|
|
|
dd = d;
|
|
|
|
|
}
|
2011-12-29 09:54:00 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
return ii;
|
2011-12-29 09:54:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
function getClosestImage(lat,lon,targetId)
|
|
|
|
|
{
|
|
|
|
|
var dd=10000;
|
|
|
|
|
var img;
|
|
|
|
|
var divImages = document.getElementById("ngimages_"+targetId);
|
|
|
|
|
var img_spans = divImages.getElementsByTagName("span");
|
|
|
|
|
for (var i = 0; i < img_spans.length; i++) {
|
|
|
|
|
var imageLat = img_spans[i].getAttribute("lat");
|
|
|
|
|
var imageLon = img_spans[i].getAttribute("lon");
|
|
|
|
|
|
|
|
|
|
imageLat = imageLat.replace(",", ".");
|
|
|
|
|
imageLon = imageLon.replace(",", ".");
|
|
|
|
|
|
2018-04-04 06:45:39 +00:00
|
|
|
|
var d = wpgpxmapsDist(imageLat, imageLon, lat, lon);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( d < dd )
|
|
|
|
|
{
|
|
|
|
|
img = img_spans[i];
|
|
|
|
|
dd = d;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return img;
|
2012-03-17 11:46:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
function isNumeric(input){
|
|
|
|
|
var RE = /^-{0,1}\d*\.{0,1}\d+$/;
|
|
|
|
|
return (RE.test(input));
|
|
|
|
|
}
|
2012-03-05 07:57:36 +00:00
|
|
|
|
|
2018-04-04 06:45:39 +00:00
|
|
|
|
function wpgpxmapsDist(lat1,lon1,lat2,lon2)
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
// mathematically not correct but fast
|
|
|
|
|
var dLat = (lat2-lat1);
|
|
|
|
|
var dLon = (lon2-lon1);
|
|
|
|
|
return Math.sqrt(dLat * dLat + dLon * dLon);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 10:56:23 +00:00
|
|
|
|
}( jQuery ));
|