From bf662e9949165d792c8d3d4fc5b6b9d1fa1e6ab6 Mon Sep 17 00:00:00 2001 From: bfabiszewski Date: Sun, 23 Jun 2013 00:17:28 +0200 Subject: various minor fixes --- README | 3 ++- api_gmaps.js | 10 ++-------- api_openlayers.js | 40 +++++++++++++++++++++++++++++++++------- config.php | 20 ++++++++++++++------ index.php | 11 +++++++---- main.css | 9 ++++++--- main.js | 5 +++-- 7 files changed, 67 insertions(+), 31 deletions(-) diff --git a/README b/README index 397c2e9..4efa1f0 100755 --- a/README +++ b/README @@ -26,7 +26,8 @@ Features: Todo - install script -- user level customization, storing settings in cookies? +- user level customization, storing settings in cookies +- custom icons - write opensource client? License diff --git a/api_gmaps.js b/api_gmaps.js index ce71491..968f9aa 100755 --- a/api_gmaps.js +++ b/api_gmaps.js @@ -26,7 +26,7 @@ var polyOptions; var mapOptions; var loadedAPI = 'gmaps'; function init() { -google.maps.visualRefresh = true; + google.maps.visualRefresh = true; polyOptions = { strokeColor: '#FF0000', strokeOpacity: 1.0, @@ -95,7 +95,7 @@ function displayTrack(xml,update) { } } -function clearMap(){ +function clearMap() { if (polies){ for (var i=0; i'; - //popup = new google.maps.InfoWindow({ - // content: contentString - //}); - //popup.open(map,markers[id]); - //altTimeout = setTimeout(function() { if (popup) {popup.close();} },2000); altTimeout = setTimeout(function() { markers[id].setIcon(icon); },2000); } }); diff --git a/api_openlayers.js b/api_openlayers.js index 7c7c622..3df53bd 100755 --- a/api_openlayers.js +++ b/api_openlayers.js @@ -31,25 +31,52 @@ function init() { var options = { controls: [ new OpenLayers.Control.ArgParser(), // default new OpenLayers.Control.Attribution(), // default - new OpenLayers.Control.LayerSwitcher({'ascending':false}), + 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); - map.addLayer(new OpenLayers.Layer.OSM()); + // default layer: OpenStreetMap + var mapnik = new OpenLayers.Layer.OSM(); + map.addLayer(mapnik); + if (layer_ocm==1) { + // OpenCycleMap + var ocm = new OpenLayers.Layer.OSM('OpenCycleMap', + ['http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png', + 'http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png', + 'http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png']); + map.addLayer(ocm); + } + if (layer_mq==1) { + // MapQuest-OSM + var mq = new OpenLayers.Layer.OSM('MapQuest-OSM', + ['http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg', + 'http://otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg', + 'http://otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg', + 'http://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', + ['http://a.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png', + 'http://b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png', + 'http://c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']); + map.addLayer(osmapa); + } var position = new OpenLayers.LonLat(21.01,52.23).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; - // init layer - layerTrack = new OpenLayers.Layer.Vector( 'Track' ); - layerMarkers = new OpenLayers.Layer.Markers( 'Markers' ); var points = new Array(); var latlngbounds = new OpenLayers.Bounds(); var positions = xml.getElementsByTagName('position'); @@ -96,7 +123,7 @@ function displayTrack(xml,update) { } } -function clearMap(){ +function clearMap() { if (layerTrack){ layerTrack.removeAllFeatures(); } @@ -152,7 +179,6 @@ function setMarker(p,i,posLen) { } } })()); - } function addChartEvent(chart) { diff --git a/config.php b/config.php index 7fc2ee1..702f382 100755 --- a/config.php +++ b/config.php @@ -17,16 +17,24 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -$version = "2.0"; +$version = "2.1"; -// map drawing framework +// default map drawing framework // (gmaps = google maps, openlayers = openlayers/osm) -$mapapi = "gmaps"; -//$mapapi = "openlayers"; +//$mapapi = "gmaps"; +$mapapi = "openlayers"; -// you may add your google maps api key +// openlayers additional map layers +// OpenCycleMap (0 = no, 1 = yes) +$layer_ocm = 1; +// MapQuest-OSM (0 = no, 1 = yes) +$layer_mq = 1; +// osmapa.pl (0 = no, 1 = yes) +$layer_osmapa = 1; + +// you may set your google maps api key // this is not obligatory by now -//$gkey = +//$gkey = ""; // MySQL config $dbhost = ""; // mysql host, eg. localhost diff --git a/index.php b/index.php index 2149b2b..9919f8b 100755 --- a/index.php +++ b/index.php @@ -106,12 +106,15 @@ print var units = "'.$units.'"; var mapapi = "'.$mapapi.'"; var gkey = '.(isset($gkey)?'"'.$gkey.'"':'null').'; + var layer_ocm = "'.$layer_ocm.'"; + var layer_mq = "'.$layer_mq.'"; + var layer_osmapa = "'.$layer_osmapa.'"; '; if ($mapapi == "gmaps") { print -' +' '; } @@ -122,7 +125,7 @@ else { '; } print ' - + @@ -136,7 +139,7 @@ print '
'.$track_form.' - '.$lang_autoreload.' ('.$interval.' s)
+ '.$lang_autoreload.' ('.$interval.' s)
'.$lang_reload.'
@@ -152,7 +155,7 @@ print ' gpx
- +
diff --git a/main.css b/main.css index 7cee9d1..a042812 100755 --- a/main.css +++ b/main.css @@ -38,17 +38,19 @@ select { font-weight: normal; padding-top: 0.2em; } -input { +#menu input, +#login input { width: 150px; text-align: center; border: 1px solid black; } -input[type = "submit"] { +#menu input[type = "submit"], +#login input[type = "submit"] { background-color: black; color: white; border: 1px solid white; } -input[type = "checkbox"] { +#menu input[type = "checkbox"] { width: auto; } #main { @@ -67,6 +69,7 @@ input[type = "checkbox"] { width: 165px; height: 100%; background-color: #666; + overflow: hidden; } #menu-content { padding: 10px; diff --git a/main.js b/main.js index 35c8074..bd16562 100755 --- a/main.js +++ b/main.js @@ -289,7 +289,7 @@ function loadMapAPI(api) { var url = new Array(); if (api=='gmaps') { url.push('api_gmaps.js'); - url.push('https://maps.googleapis.com/maps/api/js?'+((gkey!==null)?('key='+gkey+'&'):'')+'sensor=false&callback=init'); + url.push('//maps.googleapis.com/maps/api/js?'+((gkey!==null)?('key='+gkey+'&'):'')+'sensor=false&callback=init'); } else { url.push('api_openlayers.js'); @@ -341,7 +341,8 @@ function isScriptLoaded(url) { scripts = document.getElementsByTagName('script'); for (var i = scripts.length; i--;) { // check if url matches src - if (scripts[i].src != '' && url.indexOf(scripts[i].src) !== -1) return true; + var scriptUrl = scripts[i].src.replace(/https?:/,''); + if (scriptUrl != '' && url.indexOf(scriptUrl) !== -1) return true; } return false; } -- cgit v1.2.3