标签:sla reac oom const parser max devices ice new
This sample shows how to work with an OGC Web Map Service (WMS). When WMSLayers are added to the map only the specified layers are displayed. The code below creates a new
WMSLayer
then uses the visibleLayers constructor option to specify which layers are displayed.
var wmsLayer = new WMSLayer(wmsURL,{resourceInfo: resourceInfo,visibleLayers: ["1","2"]});
Note that in the code above a
resourceInfo
object is also provided. The resourceInfo object is used to define information about the service such as extent, layers, version etc. The benefit to specifying the resource info is that a proxy is not needed to work with WMS layers.
var layer1 = new WMSLayerInfo({name:"1",title:"Rivers"});var layer2 = new WMSLayerInfo({name:"2",title:"Cities"});var resourceInfo = {extent: new Extent(-126.405,31.02,-109.66,41.52,{wkid: 4326}),layerInfos: [layer1,layer2]};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Map with WMS</title>
<link rel="stylesheet" href="http://jsapi.thinkgis.cn/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://jsapi.thinkgis.cn/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="http://jsapi.thinkgis.cn/"></script>
<script>
var map;
require([
‘esri/map‘, ‘esri/layers/WMSLayer‘, ‘esri/layers/WMSLayerInfo‘, ‘esri/geometry/Extent‘,
‘dojo/_base/array‘, ‘dojo/dom‘, ‘dojo/dom-construct‘, ‘dojo/parser‘,
‘dijit/layout/BorderContainer‘, ‘dijit/layout/ContentPane‘, ‘dojo/domReady!‘
], function(Map, WMSLayer, WMSLayerInfo, Extent, array, dom, domConst, parser) {
parser.parse();
map = new Map(‘map‘, {
basemap: ‘streets‘,
center: [-96, 37],
zoom: 4
});
var layer1 = new WMSLayerInfo({
name: ‘1‘,
title: ‘Rivers‘
});
var layer2 = new WMSLayerInfo({
name: ‘2‘,
title: ‘Cities‘
});
var resourceInfo = {
extent: new Extent(-