From 4c8060f952e55a758f4b97dfd40c6bf5cd9f8a8a Mon Sep 17 00:00:00 2001 From: Zach Glueckert Date: Fri, 17 Feb 2017 15:01:24 -0500 Subject: [PATCH] Add WMS example --- examples/WMS.html | 46 ++++++++++++++++++++++++++++++ examples/WMS.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 examples/WMS.html create mode 100644 examples/WMS.js diff --git a/examples/WMS.html b/examples/WMS.html new file mode 100644 index 00000000..ffc49df3 --- /dev/null +++ b/examples/WMS.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + +
+ +
+
+

Projection

+ +
+

Layers

+
+
+
+

Destination

+ +
+
+ + Your browser does not support HTML5 Canvas. + +
+
+
+ + \ No newline at end of file diff --git a/examples/WMS.js b/examples/WMS.js new file mode 100644 index 00000000..22c2d8d4 --- /dev/null +++ b/examples/WMS.js @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2014 United States Government as represented by the Administrator of the + * National Aeronautics and Space Administration. All Rights Reserved. + */ + +requirejs(['../src/WorldWind', + './LayerManager', + '../src/layer/WmsLayer'], + function (ww, + LayerManager, + WmsLayer) { + "use strict"; + + WorldWind.Logger.setLoggingLevel(WorldWind.Logger.LEVEL_WARNING); + + var wwd = new WorldWind.WorldWindow("canvasOne"); + + var layers = [ + {layer: new WorldWind.BMNGLayer(), enabled: true}, + {layer: new WorldWind.BMNGLandsatLayer(), enabled: false}, + {layer: new WorldWind.BingAerialLayer(null), enabled: false}, + {layer: new WorldWind.BingAerialWithLabelsLayer(null), enabled: false}, + {layer: new WorldWind.BingRoadsLayer(null), enabled: false}, + {layer: new WorldWind.CompassLayer(), enabled: true}, + {layer: new WorldWind.CoordinatesDisplayLayer(wwd), enabled: true}, + {layer: new WorldWind.ViewControlsLayer(wwd), enabled: true} + ]; + + // Web Map Service information from NASA's Near Earth Observations WMS + var serviceAddress = "http://neowms.sci.gsfc.nasa.gov/wms/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0"; + // Layer displaying Average Temparature + var layerName = "MOD_LSTD_CLIM_M"; + + // Callback function to execute upon retrieval of the XML WMS GetCapabilities document + var createWmsLayer = function () { + // Create a WmsCapabilities object from the returned XML + var wms = new WorldWind.WmsCapabilities(this.responseXML); + // Retrieve a WmsLayerCapabilities object by the desired layer name + var wmsLayerCapabilities = wms.getNamedLayer(layerName); + // Form a configuration object from the WmsLayerCapability object + var wmsConfig = WmsLayer.formLayerConfiguration(wmsLayerCapabilities); + // Modify a configuration property (optional) + wmsConfig.title = "Average Surface Temp"; + // Create the WMS Layer + var wmsLayer = new WorldWind.WmsLayer(wmsConfig); + + // Add to the existing list of layers + layers.push( + {layer: wmsLayer, enabled: true} + ); + + // Add the layers to World Wind and create the layer manager + createLayerManager(); + } + + var createLayerManager = function () { + for (var l = 0; l < layers.length; l++) { + layers[l].layer.enabled = layers[l].enabled; + wwd.addLayer(layers[l].layer); + } + + // Create a layer manager for controlling layer visibility. + var layerManger = new LayerManager(wwd); + } + + // Execute the WMS XML GetCapabilities request + var req = new XMLHttpRequest(); + req.addEventListener('load', createWmsLayer); + req.open('GET', serviceAddress); + req.send(); + }); \ No newline at end of file