diff --git a/public_html/config.js b/public_html/config.js index 505d516..7e35039 100644 --- a/public_html/config.js +++ b/public_html/config.js @@ -40,6 +40,20 @@ SiteLon = 9.0; SiteName = "My Radar Site"; // tooltip of the marker +// Extra map types to include. These work for maps with 256x256 tiles where a +// URL can be constructed by simple substition of x/y tile number and zoom level +var ExtraMapTypes = { + 'OpenStreetMap' : 'http://tile.openstreetmap.org/{z}/{x}/{y}.png', + // NB: the following generally only cover the US + 'Sectional Charts' : 'http://wms.chartbundle.com/tms/1.0.0/sec/{z}/{x}/{y}.png?origin=nw', + 'Terminal Charts' : 'http://wms.chartbundle.com/tms/1.0.0/tac/{z}/{x}/{y}.png?origin=nw', + 'World Charts' : 'http://wms.chartbundle.com/tms/1.0.0/wac/{z}/{x}/{y}.png?origin=nw', + 'IFR Low Charts' : 'http://wms.chartbundle.com/tms/1.0.0/enrl/{z}/{x}/{y}.png?origin=nw', + 'IFR Area Charts' : 'http://wms.chartbundle.com/tms/1.0.0/enra/{z}/{x}/{y}.png?origin=nw', + 'IFR High Charts' : 'http://wms.chartbundle.com/tms/1.0.0/enrh/{z}/{x}/{y}.png?origin=nw' +}; + + // -- Marker settings ------------------------------------- // These settings control the coloring of aircraft by altitude. diff --git a/public_html/script.js b/public_html/script.js index f79c8ca..79a3e2d 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -306,6 +306,10 @@ function end_load_history() { } +function generic_gettile(template, coord, zoom) { + return template.replace('{x}', coord.x).replace('{y}', coord.y).replace('{z}', zoom) +} + // Initalizes the map and starts up our timers to call various functions function initialize_map() { // Load stored map settings if present @@ -336,10 +340,13 @@ function initialize_map() { for(var type in google.maps.MapTypeId) { mapTypeIds.push(google.maps.MapTypeId[type]); } - // Push OSM on to the end - mapTypeIds.push("OSM"); + mapTypeIds.push("dark_map"); + for (var type in ExtraMapTypes) { + mapTypeIds.push(type); + } + // Styled Map to outline airports and highways var styles = [ { @@ -423,19 +430,18 @@ function initialize_map() { }; GoogleMap = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); - - //Define OSM map type pointing at the OpenStreetMap tile server - GoogleMap.mapTypes.set("OSM", new google.maps.ImageMapType({ - getTileUrl: function(coord, zoom) { - return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png"; - }, - tileSize: new google.maps.Size(256, 256), - name: "OpenStreetMap", - maxZoom: 18 - })); - GoogleMap.mapTypes.set("dark_map", styledMap); + // Define the extra map types + for (var type in ExtraMapTypes) { + GoogleMap.mapTypes.set(type, new google.maps.ImageMapType({ + getTileUrl: generic_gettile.bind(null, ExtraMapTypes[type]), + tileSize: new google.maps.Size(256, 256), + name: type, + maxZoom: 18 + })); + } + // Listeners for newly created Map google.maps.event.addListener(GoogleMap, 'center_changed', function() { localStorage['CenterLat'] = GoogleMap.getCenter().lat();