mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2026-01-18 15:12:57 +00:00
Add WMS example
This commit is contained in:
parent
be0359c663
commit
4c8060f952
46
examples/WMS.html
Normal file
46
examples/WMS.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<!--@version $Id: BasicExample.html 3314 2015-07-10 18:28:45Z dcollins $-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!--NOTE: Most Web World Wind examples use jquery, Bootstrap and requirejs but those technologies are NOT-->
|
||||
<!--required by Web World Wind. See SimplestExample.html for an example of using Web World Wind without them.-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
||||
<script data-main="WMS" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="jumbotron hidden-xs">
|
||||
<h1 style="text-align:center">World Wind WMS</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<h4>Projection</h4>
|
||||
<div class="dropdown" id="projectionDropdown">
|
||||
</div>
|
||||
<br>
|
||||
<h4>Layers</h4>
|
||||
<div class="list-group" id="layerList">
|
||||
</div>
|
||||
<br>
|
||||
<h4>Destination</h4>
|
||||
<div class="input-group" id="searchBox">
|
||||
<input type="text" class="form-control" placeholder="GoTo" id="searchText"/>
|
||||
<span class="input-group-btn">
|
||||
<button id="searchButton" class="btn btn-primary" type="button">
|
||||
<span class="glyphicon glyphicon-search"></span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9" id="globe">
|
||||
<canvas id="canvasOne" width="1000" height="1000" style="width: 100%; height: auto">
|
||||
Your browser does not support HTML5 Canvas.
|
||||
</canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
71
examples/WMS.js
Normal file
71
examples/WMS.js
Normal file
@ -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();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user