package com.esri.ags.samples { import com.esri.ags.SpatialReference; import com.esri.ags.Units; import com.esri.ags.geometry.Extent; import com.esri.ags.layers.DynamicMapServiceLayer; import flash.display.Loader; import flash.net.URLRequest; import flash.net.URLVariables; /** * WMSLayer */ public class WMSLayer extends DynamicMapServiceLayer { //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Creates a new WMSLayer object. */ public function WMSLayer() { super(); setLoaded(true); // Map will only use loaded layers // init constant parameter values _params = new URLVariables(); _params.REQUEST = "GetMap"; _params.TRANPARENT = "true"; _params.FORMAT = "image/png"; _params.VERSION = "1.1.1"; _params.LAYERS = "Flood_Hazard_Zones_General"; _params.STYLES = ""; _params.SERVICE = "WMS"; _params.SERVICENAME = "WMS"; var url:String = "http://hazards.fema.gov/wmsconnector/wmsconnector/Servlet/NFHL"; // var url:String = "http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?"; _urlRequest = new URLRequest(url); //_urlRequest.data = _params; // set params on URLRequest object } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- private var _params:URLVariables; private var _urlRequest:URLRequest; //-------------------------------------------------------------------------- // // Overridden properties // initialExtent() // spatialReference() // units() // //-------------------------------------------------------------------------- //---------------------------------- // initialExtent // - needed if Map doesn't have an extent //---------------------------------- override public function get initialExtent():Extent { return new Extent(-105.261295716 ,39.467332551,-104.545150425 ,40.065272394, new SpatialReference(4326)); } //---------------------------------- // spatialReference // - needed if Map doesn't have a spatialReference //---------------------------------- override public function get spatialReference():SpatialReference { return new SpatialReference(4326); } //---------------------------------- // units // - needed if Map doesn't have it set //---------------------------------- override public function get units():String { return Units.DECIMAL_DEGREES; } //-------------------------------------------------------------------------- // // Overridden methods // loadMapImage(loader:Loader):void // //-------------------------------------------------------------------------- override protected function loadMapImage(loader:Loader):void { // update changing values _params.BBOX = map.extent.xmin.toString() + "," + map.extent.ymin.toString() + "," + map.extent.xmax.toString() + "," + map.extent.ymax.toString() ; _params.SRS = "EPSG:4326"; // _params.WIDTH = map.width; // _params.HEIGHT = map.height; //for the FEMA WMS layer, the max size they allow is 1024x1024 _params.WIDTH = 1024; _params.HEIGHT = 1024; /* We have to format our URL parameters as a string because the the bounding box parameters will get messed up if we don't */ var urlParams:String; urlParams = "FORMAT=" + _params.FORMAT + "&" + "HEIGHT=" + _params.HEIGHT + "&" + "BBOX=" + _params.BBOX + "&" + "WIDTH=" + _params.WIDTH + "&" + "LAYERS=" + _params.LAYERS + "&" + "SRS=" + _params.SRS + "&" + "VERSION=" + _params.VERSION + "&" + "STYLES=" + _params.STYLES + "&" + "REQUEST=" + _params.REQUEST + "&" + "SERVICE=" + _params.SERVICE + "&" + "TRANPARENT=" + _params.TRANPARENT + "&" + "SERVICENAME=" + _params.SERVICENAME; _urlRequest.data = urlParams; loader.load(_urlRequest); } } }
<esri:Map width="1024" height="768"> <esri:extent> <esri:Extent xmin="-120" ymin="34.1" xmax="-119.3" ymax="34.6"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/> <esri:WMSLayer skipGetCapabilities="true" url="http://hazards.fema.gov/wmsconnector/wmsconnector/Servlet/NFHL" version="1.1.1"> <esri:visibleLayers> <s:ArrayList> <fx:String>Flood_Hazard_Zones_General</fx:String> </s:ArrayList> </esri:visibleLayers> </esri:WMSLayer> </esri:Map>
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.