Add generic map type config for maps that can be handled by simple URL pattern substitution.
This commit is contained in:
parent
482d3a1d38
commit
f8a3c46139
|
@ -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.
|
||||
|
|
|
@ -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,18 +430,17 @@ function initialize_map() {
|
|||
};
|
||||
|
||||
GoogleMap = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
|
||||
GoogleMap.mapTypes.set("dark_map", styledMap);
|
||||
|
||||
//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";
|
||||
},
|
||||
// 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: "OpenStreetMap",
|
||||
name: type,
|
||||
maxZoom: 18
|
||||
}));
|
||||
|
||||
GoogleMap.mapTypes.set("dark_map", styledMap);
|
||||
}
|
||||
|
||||
// Listeners for newly created Map
|
||||
google.maps.event.addListener(GoogleMap, 'center_changed', function() {
|
||||
|
|
Loading…
Reference in a new issue