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-08-06 06:47:55 +00:00
|
|
|
|
Version: 1.6.02
|
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
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var WPGPXMAPS = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
Utils: {
|
|
|
|
|
|
|
|
|
|
// In case of multiple polylines this function divide the points of each polyline.
|
|
|
|
|
DividePolylinesPoints: function( mapData ) {
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var lastCut = 0;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var result = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
var _len = mapData.length;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
for ( i = 0; i < _len; i++ ) {
|
|
|
|
|
if ( mapData[i] == null ) {
|
|
|
|
|
result.push( mapData.slice( lastCut == 0 ? 0 : lastCut + 1, i ) );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
lastCut = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( ( _len - 1 ) != lastCut ) {
|
|
|
|
|
result.push( mapData.slice( lastCut ) );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
return result;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
GetItemFromArray: function( arr, index ) {
|
|
|
|
|
try {
|
|
|
|
|
return arr[index];
|
|
|
|
|
} catch ( e ) {
|
|
|
|
|
return [ 0, 0 ];
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
MapEngines: {
|
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
|
/* NOT WORKING AND TESTED! old code copy&paste */
|
2019-06-18 07:09:56 +00:00
|
|
|
|
GoogleMaps: function() {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.map = null,
|
|
|
|
|
this.EventSelectChart = null,
|
|
|
|
|
this.Polylines = [],
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.init = function( targetElement, mapType, scrollWheelZoom, ThunderforestApiKey ) {
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var mapTypeIds = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
for ( var type in google.maps.MapTypeId ) {
|
|
|
|
|
mapTypeIds.push( google.maps.MapTypeId[type] );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
mapTypeIds.push( 'OSM1' );
|
|
|
|
|
mapTypeIds.push( 'OSM2' );
|
|
|
|
|
mapTypeIds.push( 'OSM3' );
|
|
|
|
|
mapTypeIds.push( 'OSM4' );
|
|
|
|
|
mapTypeIds.push( 'OSM5' );
|
|
|
|
|
mapTypeIds.push( 'OSM6' );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var ngImageMarkers = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
switch ( mapType ) {
|
2018-07-27 15:21:52 +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;}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
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;}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
default: { mapType = google.maps.MapTypeId.HYBRID; break;}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( mapType == 'TERRAIN' || mapType == 'SATELLITE' || mapType == 'ROADMAP' ) {
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
// google maps
|
|
|
|
|
} else {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
// Show OpenStreetMaps credits
|
2019-06-18 07:09:56 +00:00
|
|
|
|
$( el_osm_credits ).show();
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.map = new google.maps.Map( el_map, {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
mapTypeId: mapType,
|
2019-06-18 07:09:56 +00:00
|
|
|
|
scrollwheel: ( zoomOnScrollWheel == 'true' ),
|
2018-07-27 15:21:52 +00:00
|
|
|
|
mapTypeControlOptions: {
|
|
|
|
|
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
|
|
|
|
|
mapTypeIds: mapTypeIds
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.map.mapTypes.set( 'OSM1', new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function( coord, zoom ) {
|
|
|
|
|
return "https://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + '.png';
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
tileSize: new google.maps.Size( 256, 256 ),
|
|
|
|
|
name: 'OSM',
|
|
|
|
|
alt: 'Open Street Map',
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}) );
|
2012-03-18 10:44:11 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.map.mapTypes.set( 'OSM2', new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function( coord, zoom ) {
|
|
|
|
|
if ( hasThunderforestApiKey ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/cycle/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
return "http://a.tile.opencyclemap.org/cycle/" + zoom + "/" + coord.x + "/" + coord.y + '.png';
|
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
tileSize: new google.maps.Size( 256, 256 ),
|
|
|
|
|
name: 'OCM',
|
|
|
|
|
alt: 'Open Cycle Map',
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18
|
|
|
|
|
}));
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.map.mapTypes.set( 'OSM4', new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function( coord, zoom ) {
|
|
|
|
|
if ( hasThunderforestApiKey ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/transport/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
return "http://a.tile2.opencyclemap.org/transport/" + zoom + "/" + coord.x + "/" + coord.y + '.png';
|
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
|
|
|
|
tileSize: new google.maps.Size(256, 256),
|
2019-06-18 07:09:56 +00:00
|
|
|
|
name: 'OCM-Tran',
|
|
|
|
|
alt: 'Open Cycle Map - Transport',
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}) );
|
|
|
|
|
|
|
|
|
|
this.map.mapTypes.set( 'OSM5', new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function( coord, zoom ) {
|
|
|
|
|
if ( hasThunderforestApiKey ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
return "https://a.tile.thunderforest.com/landscape/" + zoom + "/" + coord.x + "/" + coord.y + ".png?apikey=" + ThunderforestApiKey;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
return "http://a.tile3.opencyclemap.org/landscape/" + zoom + "/" + coord.x + "/" + coord.y + '.png';
|
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
tileSize: new google.maps.Size( 256, 256 ),
|
|
|
|
|
name: 'OCM-Land',
|
|
|
|
|
alt: 'Open Cycle Map - Landscape',
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}) );
|
|
|
|
|
|
|
|
|
|
this.map.mapTypes.set( 'OSM6', new google.maps.ImageMapType({
|
|
|
|
|
getTileUrl: function( coord, zoom ) {
|
|
|
|
|
return "https://tile2.maptoolkit.net/terrain/" + zoom + "/" + coord.x + "/" + coord.y + '.png';
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
tileSize: new google.maps.Size( 256, 256 ),
|
|
|
|
|
name: 'MTK-Terr',
|
|
|
|
|
alt: 'MapToolKit - Terrain',
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}) );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.AppPolylines = function( mapData, color1, currentIcon, startIcon, endIcon ) {
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var points = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var lastCut = 0;
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var polylinenes = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var polyline_number = 0;
|
|
|
|
|
var color = 0;
|
|
|
|
|
for ( i = 0; i < mapData.length; i++ ) {
|
|
|
|
|
if (mapData[i] == null) {
|
2012-04-12 14:49:22 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var poly = new google.maps.Polyline({
|
|
|
|
|
path: points.slice(lastCut,i),
|
|
|
|
|
strokeColor: color,
|
|
|
|
|
strokeOpacity: .7,
|
|
|
|
|
strokeWeight: 4,
|
|
|
|
|
map: this.map
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
polylinenes.push( poly );
|
|
|
|
|
lastCut = i;
|
|
|
|
|
polyline_number = polyline_number +1;
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
//var p = new google.maps.LatLng(mapData[i-1][0], mapData[i-1][1]);
|
|
|
|
|
//points.push(p);
|
|
|
|
|
//bounds.extend(p);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
var p = new google.maps.LatLng( mapData[i][0], mapData[i][1]);
|
|
|
|
|
points.push( p );
|
|
|
|
|
bounds.extend( p );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( points.length != lastCut ) {
|
|
|
|
|
if ( polyline_number < color1.length ) {
|
|
|
|
|
color = color1[polyline_number];
|
|
|
|
|
} else {
|
|
|
|
|
color = color1[color1.length - 1];
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
var poly = new google.maps.Polyline({
|
2019-06-18 07:09:56 +00:00
|
|
|
|
path: points.slice( lastCut ),
|
2018-07-27 15:21:52 +00:00
|
|
|
|
strokeColor: color,
|
|
|
|
|
strokeOpacity: .7,
|
|
|
|
|
strokeWeight: 4,
|
|
|
|
|
map: this.map
|
|
|
|
|
});
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
polylinenes.push( poly );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
currentPoints = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
polyline_number = polyline_number + 1;
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( startIcon != '' ) {
|
|
|
|
|
var startIconImage = new google.maps.MarkerImage( startIcon );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var startMarker = new google.maps.Marker({
|
|
|
|
|
position: points[0],
|
|
|
|
|
map: this.map,
|
|
|
|
|
title: "Start",
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
icon: startIconImage,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( endIcon != '' ) {
|
|
|
|
|
var endIconImage = new google.maps.MarkerImage( endIcon );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var startMarker = new google.maps.Marker({
|
|
|
|
|
position: points[ points.length -1 ],
|
|
|
|
|
map: this.map,
|
|
|
|
|
title: "Start",
|
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
|
icon: endIconImage,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var first = WPGPXMAPS.Utils.GetItemFromArray( mapData, 0 )
|
|
|
|
|
|
|
|
|
|
if ( currentIcon == '' ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
currentIcon = "https://maps.google.com/mapfiles/kml/pal4/icon25.png";
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var current = new google.maps.MarkerImage(currentIcon,
|
2019-06-18 07:09:56 +00:00
|
|
|
|
new google.maps.Size( 32, 32 ),
|
|
|
|
|
new google.maps.Point( 0 ,0 ),
|
|
|
|
|
new google.maps.Point( 16, 16 )
|
2018-07-27 15:21:52 +00:00
|
|
|
|
);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var marker = new google.maps.Marker({
|
2019-06-18 07:09:56 +00:00
|
|
|
|
position: new google.maps.LatLng( first[0], first[1] ),
|
2018-07-27 15:21:52 +00:00
|
|
|
|
title:"Start",
|
|
|
|
|
icon: current,
|
|
|
|
|
map: this.map,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
2012-06-04 12:31:21 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
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 );
|
|
|
|
|
if ( myChart ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var l1 = event.latLng.lat();
|
|
|
|
|
var l2 = event.latLng.lng();
|
|
|
|
|
var ci = getClosestIndex(mapData,l1,l2);
|
|
|
|
|
var activeElements = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var seriesLen = myChart.data.datasets.length;
|
|
|
|
|
for ( var i = 0; i<seriesLen;i++ ) {
|
|
|
|
|
activeElements.push( myChart.chart.getDatasetMeta( i ).data[ci] );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( activeElements.length > 0) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.options.customLine.x = activeElements[0]._model.x;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( isNaN( myChart.tooltip._eventPosition ) ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.tooltip._eventPosition = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
x: activeElements[0]._model.x,
|
2018-07-27 15:21:52 +00:00
|
|
|
|
y: activeElements[0]._model.y
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.tooltip._active = activeElements;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
myChart.tooltip.update ( true );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.draw();
|
|
|
|
|
}
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.AddWaypoints = function( waypoints, waypointIcon ) {
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.MoveMarkerToPosition = function( LatLon, updateChart ) {
|
|
|
|
|
|
2012-06-04 12:31:21 +00:00
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
Leaflet: function() {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.Bounds = [],
|
|
|
|
|
this.lng = {},
|
|
|
|
|
this.map = null,
|
|
|
|
|
this.EventSelectChart = null,
|
|
|
|
|
this.Polylines = [],
|
|
|
|
|
this.CurrentPositionMarker = null,
|
2018-08-01 12:18:31 +00:00
|
|
|
|
this.CurrentGPSPositionMarker = null,
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.init = function( targetElement, mapType, scrollWheelZoom, ThunderforestApiKey ) {
|
|
|
|
|
|
|
|
|
|
this.map = L.map( targetElement,
|
|
|
|
|
{
|
|
|
|
|
scrollWheelZoom : scrollWheelZoom,
|
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
// create fullscreen control
|
|
|
|
|
var fsControl = new L.Control.FullScreen();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
// add fullscreen control to the map
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.map.addControl( fsControl );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}).addTo( this.map );
|
|
|
|
|
|
|
|
|
|
var hasThunderforestApiKey = ( ThunderforestApiKey + '' ).length > 0;
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
|
|
|
|
var baseMaps = {};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var overlayMaps = { };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var defaultMpaLayer = null;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( hasThunderforestApiKey ) {
|
|
|
|
|
baseMaps['Open Cycle Map'] = L.tileLayer( 'https://a.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + ThunderforestApiKey, {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['Open Cycle Map - Transport'] = L.tileLayer( 'https://a.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=' + ThunderforestApiKey, {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
baseMaps['Open Cycle Map - Landscape'] = L.tileLayer( 'https://a.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + ThunderforestApiKey, {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
baseMaps['Open Cycle Map'] = L.tileLayer( 'http://a.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['Open Cycle Map - Transport'] = L.tileLayer( 'https://a.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['Open Cycle Map - Landscape'] = L.tileLayer( 'https://a.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
baseMaps['Open Street Map'] = L.tileLayer( 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['MapToolKit - Terrain'] = L.tileLayer( 'https://tile2.maptoolkit.net/terrain/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['Humanitarian Map Style'] = L.tileLayer( 'https://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
|
|
|
|
/*
|
2019-06-18 07:09:56 +00:00
|
|
|
|
baseMaps['Open Ski Map'] = L.tileLayer( 'http://tiles.skimap.org/openskimap/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
|
|
|
|
});
|
|
|
|
|
*/
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
baseMaps['Hike & Bike'] = L.tileLayer( 'http://toolserver.org/tiles/hikebike/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
baseMaps['Open Sea Map'] = L.tileLayer( 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
maxZoom: 18,
|
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
|
|
|
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
|
|
|
|
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
switch ( mapType ) {
|
|
|
|
|
case 'OSM1': {
|
|
|
|
|
baseMaps['Open Street Map'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM2': {
|
|
|
|
|
baseMaps['Open Cycle Map'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM4': {
|
|
|
|
|
baseMaps['Open Cycle Map - Transport'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM5': {
|
|
|
|
|
baseMaps['Open Cycle Map - Landscape'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM6': {
|
|
|
|
|
baseMaps['MapToolKit - Terrain'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM7': {
|
|
|
|
|
baseMaps['Humanitarian Map Style'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM8': {
|
|
|
|
|
baseMaps['Open Ski Map'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM9': {
|
|
|
|
|
baseMaps['Hike & Bike'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
case 'OSM10': {
|
|
|
|
|
baseMaps['Open Sea Map'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
default: {
|
|
|
|
|
baseMaps['Open Street Map'].addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
L.control.layers( baseMaps, overlayMaps ).addTo( this.map );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.AppPolylines = function( mapData, color1, currentIcon, startIcon, endIcon ) {
|
|
|
|
|
|
|
|
|
|
var first = WPGPXMAPS.Utils.GetItemFromArray( mapData, 0 );
|
|
|
|
|
|
|
|
|
|
if ( currentIcon == '' ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
currentIcon = "https://maps.google.com/mapfiles/kml/pal4/icon25.png";
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
var CurrentPositionMarker = L.marker( first, { icon: L.icon ({
|
|
|
|
|
iconUrl: currentIcon,
|
|
|
|
|
iconSize: [32, 32], // size of the icon
|
|
|
|
|
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
CurrentPositionMarker.addTo( this.map );
|
|
|
|
|
CurrentPositionMarker.title = 'Start';
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.CurrentPositionMarker = CurrentPositionMarker;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
var pointsArray = WPGPXMAPS.Utils.DividePolylinesPoints( mapData );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var lng = this.lng;
|
|
|
|
|
var EventSelectChart = this.EventSelectChart;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.Bounds = mapData;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.CenterMap();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
for ( i = 0; i < pointsArray.length; i++ ) {
|
|
|
|
|
|
|
|
|
|
if ( i < color1.length ) {
|
|
|
|
|
color = color1[i];
|
|
|
|
|
} else {
|
|
|
|
|
color = color1[color1.length - 1];
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
try {
|
|
|
|
|
var polyline = L.polyline( pointsArray[i], {color: color} ).addTo( this.map );
|
|
|
|
|
this.Polylines.push( polyline );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var context = this;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.Polylines[i].on('mousemove', function( e ) {
|
|
|
|
|
context.MoveMarkerToPosition( [e.latlng.lat, e.latlng.lng], true );
|
|
|
|
|
});
|
|
|
|
|
} catch ( err ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( startIcon != '' ) {
|
|
|
|
|
|
|
|
|
|
var startMarker = L.marker( mapData[0], {icon: L.icon( {
|
|
|
|
|
iconUrl: startIcon,
|
|
|
|
|
iconSize: [32, 32], // size of the icon
|
|
|
|
|
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
startMarker.addTo( this.map );
|
|
|
|
|
startMarker.title = 'Start';
|
|
|
|
|
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( endIcon != '' ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var endMarker = L.marker( mapData[ mapData.length - 1 ], {icon: L.icon( {
|
|
|
|
|
iconUrl: endIcon,
|
|
|
|
|
iconSize: [32, 32], // size of the icon
|
|
|
|
|
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
endMarker.addTo( this.map );
|
|
|
|
|
endMarker.title = 'End';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2018-07-27 15:21:52 +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)
|
|
|
|
|
);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var marker = new google.maps.Marker({
|
|
|
|
|
position: new google.maps.LatLng(first[0], first[1]),
|
|
|
|
|
title:"Start",
|
|
|
|
|
icon: current,
|
|
|
|
|
map: map,
|
|
|
|
|
zIndex: 10
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
for (i=0; i < polylinenes.length; i++)
|
|
|
|
|
{
|
2018-07-27 15:21:52 +00:00
|
|
|
|
|
|
|
|
|
google.maps.event.addListener(polylinenes[i],'mouseover',function(event){
|
|
|
|
|
if (marker)
|
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
marker.setPosition(event.latLng);
|
2018-07-27 15:21:52 +00:00
|
|
|
|
marker.setTitle(lng.currentPosition);
|
|
|
|
|
if (myChart)
|
|
|
|
|
{
|
|
|
|
|
var l1 = event.latLng.lat();
|
|
|
|
|
var l2 = event.latLng.lng();
|
|
|
|
|
var ci = getClosestIndex(mapData,l1,l2);
|
|
|
|
|
var activeElements = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var seriesLen = myChart.data.datasets.length;
|
2018-07-27 15:21:52 +00:00
|
|
|
|
for(var i=0; i<seriesLen;i++)
|
|
|
|
|
{
|
|
|
|
|
activeElements.push(myChart.chart.getDatasetMeta(i).data[ci]);
|
|
|
|
|
}
|
|
|
|
|
if (activeElements.length > 0)
|
|
|
|
|
{
|
|
|
|
|
myChart.options.customLine.x = activeElements[0]._model.x;
|
|
|
|
|
if (isNaN(myChart.tooltip._eventPosition))
|
|
|
|
|
{
|
|
|
|
|
myChart.tooltip._eventPosition = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
x: activeElements[0]._model.x,
|
2018-07-27 15:21:52 +00:00
|
|
|
|
y: activeElements[0]._model.y
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.tooltip._active = activeElements;
|
|
|
|
|
myChart.tooltip.update(true);
|
|
|
|
|
myChart.draw();
|
|
|
|
|
}
|
2012-03-17 11:46:00 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
});
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.AddWaypoints = function( waypoints, waypointIcon ) {
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var icon = L.icon({
|
|
|
|
|
iconUrl: 'https://maps.google.com/mapfiles/ms/micons/flag.png',
|
|
|
|
|
iconSize: [32, 32], // size of the icon
|
|
|
|
|
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( waypointIcon!='' ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
icon = L.icon({
|
|
|
|
|
iconUrl: 'waypointIcon',
|
|
|
|
|
iconSize: [32, 32], // size of the icon
|
|
|
|
|
iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
for ( i = 0; i < waypoints.length; i++ ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var wpt = waypoints[i];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.Bounds.push( [wpt.lat,wpt.lon] );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var lat= wpt.lat;
|
|
|
|
|
var lon= wpt.lon;
|
|
|
|
|
var sym= wpt.sym;
|
|
|
|
|
var typ= wpt.type;
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( icon.img ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
icon.iconUrl = wpt.img;
|
|
|
|
|
wsh = '';
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var marker = L.marker( [lat, lon], {icon: icon } );
|
|
|
|
|
|
|
|
|
|
var cnt = '';
|
|
|
|
|
|
|
|
|
|
if ( wpt.name=='' ) {
|
|
|
|
|
cnt = "<div>" + unescape( wpt.desc ) + "</div>";
|
|
|
|
|
} else {
|
|
|
|
|
cnt = "<div><b>" + wpt.name + "</b><br />" + unescape( wpt.desc ) + "</div>";
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
cnt += "<br /><p><a href='https://maps.google.com?daddr=" + lat + "," + lon + "' target='_blank'>Itinéraire</a></p>";
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
marker.addTo( this.map ).bindPopup( cnt );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.CenterMap();
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.MoveMarkerToPosition = function( LatLon, updateChart ) {
|
|
|
|
|
if ( this.CurrentPositionMarker == null )
|
2018-07-27 15:21:52 +00:00
|
|
|
|
return;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
this.CurrentPositionMarker.setLatLng( LatLon );
|
|
|
|
|
|
|
|
|
|
if ( this.lng )
|
2018-07-27 15:21:52 +00:00
|
|
|
|
this.CurrentPositionMarker.title = this.lng.currentPosition;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
if ( updateChart == true && this.EventSelectChart )
|
|
|
|
|
this.EventSelectChart( LatLon );
|
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
this.CenterMap = function() {
|
|
|
|
|
this.map.fitBounds( this.Bounds );
|
|
|
|
|
};
|
|
|
|
|
|
2012-06-04 12:31:21 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
(function( $ ) {
|
2018-07-27 15:21:52 +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;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var currentpositioncon = params.currentpositioncon;
|
2017-03-01 09:12:32 +00:00
|
|
|
|
var ThunderforestApiKey = params.TFApiKey;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
var hasThunderforestApiKey = ( ThunderforestApiKey + '' ).length > 0;
|
|
|
|
|
|
|
|
|
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
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);
|
|
|
|
|
var el_osm_credits = document.getElementById('wpgpxmaps_' + targetId + '_osm_footer');
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var mapWidth = el_map.style.width;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var map = new WPGPXMAPS.MapEngines.Leaflet();
|
|
|
|
|
map.lng = lng;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
map.init( 'map_' + targetId,
|
|
|
|
|
mapType,
|
|
|
|
|
( zoomOnScrollWheel == 'true' ),
|
2018-07-27 15:21:52 +00:00
|
|
|
|
ThunderforestApiKey);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
map.EventSelectChart = function( LatLon ) {
|
|
|
|
|
|
|
|
|
|
if ( myChart ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var l1 = LatLon[0];
|
|
|
|
|
var l2 = LatLon[1];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var ci = getClosestIndex( mapData, l1, l2 );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var activeElements = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var seriesLen = myChart.data.datasets.length;
|
|
|
|
|
for ( var i = 0; i < seriesLen;i++ ) {
|
|
|
|
|
activeElements.push( myChart.chart.getDatasetMeta( i ).data[ci]);
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( activeElements.length > 0 ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.options.customLine.x = activeElements[0]._model.x;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( isNaN( myChart.tooltip._eventPosition ) ) {
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.tooltip._eventPosition = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
x: activeElements[0]._model.x,
|
2018-07-27 15:21:52 +00:00
|
|
|
|
y: activeElements[0]._model.y
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.tooltip._active = activeElements;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
myChart.tooltip.update( true );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
myChart.draw();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-08-01 12:18:31 +00:00
|
|
|
|
//var bounds = new google.maps.LatLngBounds();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( usegpsposition == 'true' ) {
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Try HTML5 geolocation
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( navigator.geolocation ) {
|
|
|
|
|
|
2018-08-01 12:18:31 +00:00
|
|
|
|
var context = map;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
navigator.geolocation.watchPosition( function( position ) {
|
|
|
|
|
|
2018-08-01 12:18:31 +00:00
|
|
|
|
var radius = position.coords.accuracy / 2;
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// user position
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var pos = [ position.coords.latitude, position.coords.longitude ];
|
|
|
|
|
|
|
|
|
|
if ( context.CurrentGPSPositionMarker == null ) {
|
|
|
|
|
if ( currentpositioncon == '' ) {
|
2018-08-06 06:47:55 +00:00
|
|
|
|
currentpositioncon = "https://maps.google.com/mapfiles/kml/pal4/icon25.png";
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 06:47:55 +00:00
|
|
|
|
context.CurrentGPSPositionMarker = L.marker(pos, {icon: L.icon({
|
2019-06-18 07:09:56 +00:00
|
|
|
|
iconUrl: currentpositioncon,
|
|
|
|
|
iconSize: [ 32, 32 ], // size of the icon
|
|
|
|
|
iconAnchor: [ 16, 16 ] // point of the icon which will correspond to marker's location
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.addTo( context.map )
|
|
|
|
|
.bindPopup( lng.currentPosition )
|
|
|
|
|
.openPopup();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
context.CurrentGPSPositionMarker.setLatLng( pos );
|
2018-08-01 12:18:31 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
context.Bounds.push( pos );
|
|
|
|
|
|
|
|
|
|
context.CenterMap();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
function( e ) {
|
|
|
|
|
|
2018-08-01 12:18:31 +00:00
|
|
|
|
// some errors
|
2019-06-18 07:09:56 +00:00
|
|
|
|
},
|
2018-08-01 12:18:31 +00:00
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
enableHighAccuracy: false,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
maximumAge: 0
|
2018-08-01 12:18:31 +00:00
|
|
|
|
});
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Print WayPoints
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if ( ! jQuery.isEmptyObject( waypoints ) && waypoints.length > 0 ) {
|
|
|
|
|
map.AddWaypoints( waypoints, waypointIcon );
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Print Images
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
jQuery("#ngimages_" + targetId).attr("style","display:block;position:absolute;left:-50000px");
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
var nggImages = jQuery("#ngimages_" + targetId + " span").toArray();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
if (nggImages !== undefined && nggImages.length > 0)
|
|
|
|
|
{
|
|
|
|
|
var photos = [];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
for (var i = 0; i < nggImages.length; i++) {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
var ngg_span = nggImages[i];
|
|
|
|
|
var ngg_span_a = ngg_span.children[0];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
var pos = [
|
|
|
|
|
Number(ngg_span.getAttribute("lat")),
|
2018-12-07 17:59:50 +00:00
|
|
|
|
Number(ngg_span.getAttribute("lon"))
|
|
|
|
|
];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
map.Bounds.push(pos);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
photos.push({
|
|
|
|
|
"lat": pos[0],
|
|
|
|
|
"lng": pos[1],
|
|
|
|
|
"name": ngg_span_a.getAttribute("data-title"),
|
|
|
|
|
"url": ngg_span_a.getAttribute("data-src"),
|
|
|
|
|
"thumbnail": ngg_span_a.getAttribute("data-thumbnail")
|
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
if (photos.length > 0)
|
|
|
|
|
{
|
|
|
|
|
var photoLayer = L.photo.cluster().on('click', function(evt) {
|
|
|
|
|
var photo = evt.layer.photo;
|
|
|
|
|
var template = '<img src="{url}" /></a><p>{name}</p>';
|
|
|
|
|
evt.layer.bindPopup(L.Util.template(template, photo), {
|
|
|
|
|
minWidth: 'auto',
|
|
|
|
|
}).openPopup();
|
|
|
|
|
});
|
2012-07-02 12:51:45 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
photoLayer.add(photos).addTo(map.map);
|
|
|
|
|
|
|
|
|
|
map.CenterMap();
|
|
|
|
|
|
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
/*
|
|
|
|
|
var showHideImagesCustomControl = L.Control.extend({
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
options: {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
position: 'topleft'
|
2018-12-07 17:59:50 +00:00
|
|
|
|
//control position - allowed: 'topleft', 'topright', 'bottomleft', 'bottomright'
|
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
onAdd: function (map) {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
var container = document.createElement('img');
|
|
|
|
|
container.class= "leaflet-bar leaflet-control leaflet-control-custom"
|
|
|
|
|
container.style.backgroundColor = 'white';
|
|
|
|
|
container.style.width = '30px';
|
|
|
|
|
container.style.height = '30px';
|
|
|
|
|
container.src = pluginUrl + "/wp-gpx-maps/img/hideImages.png";
|
|
|
|
|
container.style.cursor = 'pointer';
|
|
|
|
|
container.title = lng.hideImages;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
container.onclick = function(){
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
var isImagesHidden = (controlUIhi.isImagesHidden == true);
|
|
|
|
|
var mapDiv = map.getDiv();
|
|
|
|
|
var center = map.getCenter();
|
|
|
|
|
|
|
|
|
|
if (isImagesHidden)
|
2012-07-02 12:51:45 +00:00
|
|
|
|
{
|
2018-12-07 17:59:50 +00:00
|
|
|
|
for (var i=0; i<ngImageMarkers.length; i++) {
|
|
|
|
|
ngImageMarkers[i].setMap(map);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
|
|
|
|
controlUIhi.src = pluginUrl + "/wp-gpx-maps/img/hideImages.png";
|
2018-12-07 17:59:50 +00:00
|
|
|
|
controlUIhi.title = lng.hideImages;
|
2012-07-02 12:51:45 +00:00
|
|
|
|
}
|
2018-12-07 17:59:50 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (var i=0; i<ngImageMarkers.length; i++) {
|
|
|
|
|
ngImageMarkers[i].setMap(null);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-12-07 17:59:50 +00:00
|
|
|
|
controlUIhi.src = pluginUrl + "/wp-gpx-maps/img/showImages.png";
|
|
|
|
|
controlUIhi.title = lng.showImages;
|
|
|
|
|
}
|
|
|
|
|
controlUIhi.isImagesHidden = !isImagesHidden;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
return false;
|
2018-12-07 17:59:50 +00:00
|
|
|
|
|
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
return container;
|
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
map.map.addControl(new showHideImagesCustomControl());
|
|
|
|
|
*/
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
}
|
2012-10-30 14:03:16 +00:00
|
|
|
|
|
2018-12-07 17:59:50 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
/*
|
2019-06-18 07:09:56 +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
|
|
|
|
{
|
2019-06-18 07:09:56 +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);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
//get first gallery without images
|
2019-06-18 07:09:56 +00:00
|
|
|
|
for (var _temp in galleries) {
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var _gal = galleries[_temp];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (_gal.source == "random_images" && _gal.wpgpxmaps != true )
|
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
_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++)
|
2019-06-18 07:09:56 +00:00
|
|
|
|
{
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var __xx = jQuery(_xx[i]);
|
|
|
|
|
__xx.attr("data-nplmodal-gallery-id", _transient_id);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
_gal["image_ids"].push(__xx.attr("data-image-id"));
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-30 14:03:16 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
*/
|
2012-06-13 13:14:18 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// Print Track
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if (mapData != '')
|
2014-03-14 13:38:36 +00:00
|
|
|
|
{
|
2018-07-27 15:21:52 +00:00
|
|
|
|
map.AppPolylines(mapData, color1, currentIcon, startIcon, endIcon);
|
2012-03-05 07:57:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
/*
|
2019-06-18 07:09:56 +00:00
|
|
|
|
map.setCenter(bounds.getCenter());
|
2014-03-14 13:38:36 +00:00
|
|
|
|
map.fitBounds(bounds);
|
2018-07-27 15:21:52 +00:00
|
|
|
|
*/
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
// FIX post tabs
|
|
|
|
|
var $_tab = $(el).closest(".wordpress-post-tabs, .tab-pane").eq(0);
|
2014-06-09 13:18:24 +00:00
|
|
|
|
if ($_tab)
|
|
|
|
|
{
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var contextMap = map;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var FixMapSize = function(e)
|
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
setTimeout(function(e){
|
|
|
|
|
//google.maps.event.trigger(map, 'resize');
|
2018-07-27 15:21:52 +00:00
|
|
|
|
contextMap.map.invalidateSize();
|
|
|
|
|
contextMap.CenterMap();
|
2014-07-14 07:48:30 +00:00
|
|
|
|
tabResized = true;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}, 300);
|
2018-07-27 15:21:52 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
$(".wpsm_nav-tabs a").click(FixMapSize);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-07-27 15:21:52 +00:00
|
|
|
|
$("div > ul > li > a", $_tab).click(FixMapSize);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var graphh = jQuery('#myChart_' + params.targetId).css("height");
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
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;
|
2019-06-18 07:09:56 +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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
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
|
|
|
|
}
|
2019-06-18 07:09:56 +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);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (decPoint == "1")
|
|
|
|
|
decPoint = ".";
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (thousandsSep == "1")
|
2019-06-18 07:09:56 +00:00
|
|
|
|
thousandsSep = "";
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
// 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;
|
2018-07-27 15:21:52 +00:00
|
|
|
|
var point = WPGPXMAPS.Utils.GetItemFromArray(mapData,i)
|
|
|
|
|
map.MoveMarkerToPosition(point, false);
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}],
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
labels : graphDist,
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphEle != '')
|
2012-04-07 09:11:37 +00:00
|
|
|
|
{
|
2019-06-18 07:09:56 +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),
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( chartFrom1 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.min = chartFrom1;
|
|
|
|
|
yaxe.startOnTick = false;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
else {
|
|
|
|
|
yaxe.min = myData.Min;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( chartTo1 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.max = chartTo1;
|
|
|
|
|
yaxe.endOnTick = false;
|
|
|
|
|
}
|
2019-06-18 07:09:56 +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_y)
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2019-06-18 07:09:56 +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
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
if (graphSpeed != '') {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
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 };
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
l_s = { suf : "m/s", dec : 0 };
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphSpeed);
|
2014-03-14 13:38:36 +00:00
|
|
|
|
|
2019-06-18 07:09:56 +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),
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( chartFrom2 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.min = chartFrom2;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
yaxe.startOnTick = false;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
else {
|
|
|
|
|
yaxe.min = myData.Min;
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if ( chartTo2 != '' )
|
|
|
|
|
{
|
|
|
|
|
yaxe.max = chartTo2;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
yaxe.endOnTick = false;
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
else {
|
|
|
|
|
yaxe.max = myData.Max;
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_s);
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2019-06-18 07:09:56 +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
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphHr != '')
|
2011-12-14 10:35:25 +00:00
|
|
|
|
{
|
2019-06-18 07:09:56 +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 = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
type: 'linear',
|
2018-03-09 09:02:25 +00:00
|
|
|
|
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);
|
2019-06-18 07:09:56 +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
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphAtemp != '')
|
2012-04-12 14:49:22 +00:00
|
|
|
|
{
|
2019-06-18 07:09:56 +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),
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2019-06-18 07:09:56 +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 });
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2012-04-12 14:49:22 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphCad != '')
|
2013-02-04 08:58:18 +00:00
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var myData = mergeArrayForChart(graphDist, graphCad, true);
|
2019-06-18 07:09:56 +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_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),
|
|
|
|
|
};
|
2019-06-18 07:09:56 +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);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
if (graphGrade != '')
|
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
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 = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
type: 'linear',
|
2018-03-09 09:02:25 +00:00
|
|
|
|
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),
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
_formats.push(l_grade);
|
|
|
|
|
hoptions.options.scales.yAxes.push(yaxe);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
hoptions.data.datasets.push( wpgpxmapsGetDataset(lng.grade, myData.Items, color6, yaxe.id ) );
|
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +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);
|
2019-06-18 07:09:56 +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
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
return this;
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
function mergeArrayForChart(distArr, dataArr, setZerosAsNull)
|
|
|
|
|
{
|
|
|
|
|
var l = distArr.length;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
var items = new Array(l);
|
|
|
|
|
var min=10000;
|
|
|
|
|
var max=-10000;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
for (i=0; i<l; i++)
|
2018-03-09 09:02:25 +00:00
|
|
|
|
{
|
|
|
|
|
if (distArr[i] != null)
|
|
|
|
|
{
|
|
|
|
|
var _item = dataArr[i];
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
if (setZerosAsNull === true && _item === 0)
|
|
|
|
|
{
|
2019-06-18 07:09:56 +00:00
|
|
|
|
_item = null;
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
items[i] = {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
x: distArr[i],
|
2018-03-09 09:02:25 +00:00
|
|
|
|
y:_item
|
|
|
|
|
};
|
2019-06-18 07:09:56 +00:00
|
|
|
|
if (_item > max)
|
|
|
|
|
max = _item;
|
|
|
|
|
if (_item < min)
|
2018-03-09 09:02:25 +00:00
|
|
|
|
min = _item;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
return {
|
|
|
|
|
Items : items,
|
|
|
|
|
Min : min,
|
2019-06-18 07:09:56 +00:00
|
|
|
|
Max : max,
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-04-04 06:45:39 +00:00
|
|
|
|
function wpgpxmapsGetDataset(name,data,color, id) {
|
2018-03-09 09:02:25 +00:00
|
|
|
|
return {
|
2018-08-06 06:47:55 +00:00
|
|
|
|
label: name, // jQuery("<div/>").html(name).text(), // convert html special chars to text, ugly but it works
|
2018-03-09 09:02:25 +00:00
|
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
2018-03-09 09:02:25 +00:00
|
|
|
|
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');
|
|
|
|
|
}
|
2018-07-27 15:21:52 +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;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
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;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
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);
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var img_spans = divImages.getElementsByTagName("span");
|
|
|
|
|
for (var i = 0; i < img_spans.length; i++) {
|
2014-03-14 13:38:36 +00:00
|
|
|
|
var imageLat = img_spans[i].getAttribute("lat");
|
2019-06-18 07:09:56 +00:00
|
|
|
|
var imageLon = img_spans[i].getAttribute("lon");
|
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
|
imageLat = imageLat.replace(",", ".");
|
|
|
|
|
imageLon = imageLon.replace(",", ".");
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
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;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
}
|
2014-03-14 13:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
|
|
}( jQuery ));
|