-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't mock webGL in the tests; it needs to be done in the inner iframe. Allow passing through a crossDomain setting of null. Simpler tutorial titles. Order tutorials.
- Loading branch information
Showing
11 changed files
with
117 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
extends ../common/index.pug | ||
|
||
block mainTutorial | ||
:markdown-it | ||
# Tutorial - Using a WMS Tile Source | ||
When a tile layer is added to a map, the tiles can be loaded based on a templated URL or based on a URL returned from a function. When using a WMS tile server, often the request must be made in a specific coordinate system. The bounds of each tile can be requested, converted to the WMS coordinate system, and then sent as part of the URL. | ||
|
||
+codeblock('javascript', 1, undefined, true). | ||
// The default map projection is Web Mercator. We need to ask the WMS | ||
// server to use this coordinate system. | ||
var projection = 'EPSG:3857'; | ||
|
||
var map = geo.map({ | ||
node: "#map", | ||
zoom: 4, | ||
// start centered on the continental US | ||
center: {x: -98.0, y: 39.5} | ||
}); | ||
// place a base tile layer on the map | ||
map.createLayer('osm'); | ||
// create a tile layer with the WMS data | ||
map.createLayer('osm', { | ||
attribution: null, | ||
// the tiles are transparent, so don't keep the lower level ones; they | ||
// would build up | ||
keepLower: false, | ||
// the map tile URL can be generated from a function | ||
url: function (x, y, zoom) { | ||
var service = 'NWS_Observations'; | ||
var observation = 'radar_base_reflectivity'; | ||
// get data from NOAA | ||
var baseUrl = 'https://idpgis.ncep.noaa.gov/arcgis/rest/services/' + service + '/' + observation + '/MapServer/export'; | ||
|
||
// Get the bounding box of the tile in the desired projection | ||
var bb = this.gcsTileBounds({x: x, y: y, level: zoom}, projection); | ||
// make a string which the WMS server requires for the bounding box | ||
var bbSpec = bb.left + ',' + bb.bottom + ',' + bb.right + ',' + bb.top; | ||
|
||
// Set the WMS server parameters | ||
var params = { | ||
transparent: true, | ||
format: 'png32', | ||
bbox: bbSpec, | ||
bboxSR: projection.split(':')[1], | ||
imageSR: projection.split(':')[1], | ||
size: '256,256', | ||
layers: 'show:3', | ||
f: 'image' | ||
} | ||
// construct the url for a tile. We can use jQuery's $.param function. | ||
var url = baseUrl + '?' + $.param(params); | ||
return url; | ||
} | ||
}); | ||
+codeblock_test('map has two osm layers, one from a WMS server', [ | ||
'map.layers().length === 2', | ||
'map.layers()[0] instanceof geo.osmLayer', | ||
'map.layers()[1] instanceof geo.osmLayer', | ||
'geo.util.isFunction(map.layers()[1].url())' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"title": "Using a WMS Tile Source", | ||
"hideNavbar": true, | ||
"tutorialCss": [], | ||
"tutorialJs": [], | ||
"level": 0, | ||
"about": { | ||
"text": "Make a map with a custom function for getting tiles from a WMS server. This also shows how to get tile bounds in different coordinates." | ||
} | ||
} |