/* μlogger
*
* Copyright(C) 2017 Bartek Fabiszewski (www.fabiszewski.net)
*
* This is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*/
// openlayers
var map;
var layerTrack;
var layerMarkers;
var lineStyle = {strokeColor: '#FF0000', strokeOpacity: 1, strokeWidth: 2};
var wgs84;
var mercator;
var loadedAPI = 'openlayers';
function init() {
wgs84 = new OpenLayers.Projection('EPSG:4326'); // from WGS 1984
mercator = new OpenLayers.Projection('EPSG:900913'); // to Mercator
var options = { controls: [
new OpenLayers.Control.ArgParser(), // default
new OpenLayers.Control.Attribution(), // default
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Navigation(), // default
new OpenLayers.Control.PanZoomBar(),// do we need it?
new OpenLayers.Control.ScaleLine()
]
};
map = new OpenLayers.Map('map-canvas', options);
// default layer: OpenStreetMap
var mapnik = new OpenLayers.Layer.OSM('OpenStreetMap',
['//a.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//b.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//c.tile.openstreetmap.org/${z}/${x}/${y}.png']);
map.addLayer(mapnik);
if (layer_ocm==1) {
// OpenCycleMap
var ocm = new OpenLayers.Layer.OSM('OpenCycleMap',
['//a.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
'//b.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
'//c.tile.thunderforest.com/cycle/${z}/${x}/${y}.png']);
map.addLayer(ocm);
}
if (layer_mq==1) {
// MapQuest-OSM
var mq = new OpenLayers.Layer.OSM('MapQuest-OSM',
['//otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg']);
map.addLayer(mq);
}
if (layer_osmapa==1) {
// osmapa.pl
var osmapa = new OpenLayers.Layer.OSM('osmapa.pl',
['//a.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'//b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'//c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']);
map.addLayer(osmapa);
}
if (layer_ump==1) {
// UMP
var ump = new OpenLayers.Layer.OSM('UMP',
['//1.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'//2.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'//3.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png']);
map.addLayer(ump);
}
var position = new OpenLayers.LonLat(init_longitude,init_latitude).transform(wgs84, mercator);
var zoom = 8;
map.setCenter(position, zoom);
// init layers
layerTrack = new OpenLayers.Layer.Vector('Track');
layerMarkers = new OpenLayers.Layer.Markers('Markers');
}
function displayTrack(xml,update) {
altitudes.length = 0;
var totalMeters = 0;
var totalSeconds = 0;
var points = new Array();
var latlngbounds = new OpenLayers.Bounds();
var positions = xml.getElementsByTagName('position');
var posLen = positions.length;
for (var i=0; i