|
public function searchQuery_kei(LayerName:String, MapX:Number, MapY:Number, sLayerName:String="measures"):void { var mapPoint:MapPoint = new MapPoint(MapX, MapY); var diffDis:Number = 1; var GS_LayerName:String = 'nem_ecvam'; var GS_GName:String = 'ECVAM'; var GS_LayerNameFull:String = GS_GName + ':' + GS_LayerName; var urlstring:String = kei_WNS_URL; urlstring = urlstring + "/"+GS_GName+"/wms?" + 'SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&tiled=true&INFO_FORMAT=text%2Fxml' +'&FEATURE_COUNT=1&SRS=EPSG%3A900913&X=1&Y=1&WIDTH=1&HEIGHT=1' //+'&FEATURE_COUNT=1&SRS=EPSG%3A900913&X=128&Y=128&WIDTH=256&HEIGHT=256' urlstring += '&QUERY_LAYERS=' + GS_LayerNameFull; urlstring += '&LAYERS=' + GS_LayerNameFull; urlstring += '&BBOX=' + (MapX-diffDis).toString() + ',' + (MapY-diffDis).toString() + ',' + (MapX+diffDis).toString() + ',' + (MapY+diffDis).toString(); { CursorManager.setBusyCursor(); //BusyIndicator.visible = true; var httpService:mx.rpc.http.mxml.HTTPService = new mx.rpc.http.mxml.HTTPService( ); httpService.url = urlstring; httpService.addEventListener(ResultEvent.RESULT, onResult); httpService.addEventListener(FaultEvent.FAULT, onFault); httpService.send(); } function onResult(e:ResultEvent):void{ CursorManager.removeBusyCursor(); //BusyIndicator.visible = false; var GRAY_INDEX_ObjValue:String = null; var results : ArrayCollection; if(e.result.FeatureCollection.featureMember == null) { return; } else if(e.result.FeatureCollection.featureMember is ObjectProxy) { results = new ArrayCollection([e.result.FeatureCollection.featureMember]); } else { results = e.result.FeatureCollection.featureMember as ArrayCollection; } for each(var item : Object in results) { GRAY_INDEX_ObjValue = String(item[GS_LayerName].PALETTE_INDEX); } if(!GRAY_INDEX_ObjValue || (GRAY_INDEX_ObjValue == ""))GRAY_INDEX_ObjValue = "0"; if(GRAY_INDEX_ObjValue){ //표시할 레이어 초기화 var myGraphicsLayer:GraphicsLayer = mainmap.getLayer(sLayerName) as GraphicsLayer; if (!myGraphicsLayer){ myGraphicsLayer = new GraphicsLayer(); myGraphicsLayer.id = sLayerName; myGraphicsLayer.name = "hiddenLayer_" + sLayerName; mainmap.reorderLayer(myGraphicsLayer.id, GET_LayerOrder("drawGraphicsLayer")); mainmap.addLayer(myGraphicsLayer); } myGraphicsLayer.clear(); //심볼표시 var myGraphicPoint:Graphic = new Graphic(); myGraphicPoint.geometry = mapPoint; myGraphicPoint.symbol = new PictureMarkerSymbol(_icon_ipin, 30, 30); var _ObjValue:String = numberFormatter0.format(Number(GRAY_INDEX_ObjValue)); if(!_ObjValue || (_ObjValue == ""))_ObjValue = "0"; var _ObjData:String = "국토환경성평가도: " + _ObjValue + " 등급"; var _attributes :Object = new Object(); _attributes["NAME"] = _ObjData; var _toolTip:String = _ObjData; myGraphicPoint.toolTip = _toolTip; myGraphicPoint.attributes = _attributes; myGraphicsLayer.add(myGraphicPoint); //onGlowObjOne(myGraphicPoint, 3); var contentNavigator:ContentNavigator = new ContentNavigator(); contentNavigator.dataProvider = new ArrayList([ myGraphicPoint ]); mainmap.infoWindowContent = contentNavigator; mainmap.infoWindow.show(myGraphicPoint.geometry as MapPoint); } } function onFault(e:FaultEvent):void{ CursorManager.removeBusyCursor(); //BusyIndicator.visible = false; } } |
(2)생태자연도(환경부)
WMS 레이어로 레스터 서비스하는 평가도에서 쿼리한 벡터정보를 읽고 Polygon과 필드 속성을 표출하는 예제 소스
public function searchQuery_meWMS(LayerName:String, MapX:Number, MapY:Number, sLayerName:String="measures"):void { var mapPoint:MapPoint = new MapPoint(MapX, MapY); var diffDis:Number = 1; var GS_GName:String = 'EGIS'; var GS_LayerName:String = 'eco_2015_g'; var GSAdd_LayerName:String; var GS_LayerNameFull:String = GS_GName + ':' + GS_LayerName; var urlstring:String = me_WNS_URL; urlstring = urlstring + "/"+GS_GName+"/wms?" + 'SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&tiled=true&INFO_FORMAT=text%2Fxml' +'&FEATURE_COUNT=1&SRS=EPSG%3A900913&X=1&Y=1&WIDTH=1&HEIGHT=1' //+'&FEATURE_COUNT=1&SRS=EPSG%3A900913&X=128&Y=128&WIDTH=256&HEIGHT=256' urlstring += '&QUERY_LAYERS=' + GS_LayerNameFull; urlstring += '&LAYERS=' + GS_LayerNameFull; urlstring += '&BBOX=' + (MapX-diffDis).toString() + ',' + (MapY-diffDis).toString() + ',' + (MapX+diffDis).toString() + ',' + (MapY+diffDis).toString(); { CursorManager.setBusyCursor(); //BusyIndicator.visible = true; var httpService:mx.rpc.http.mxml.HTTPService = new mx.rpc.http.mxml.HTTPService( ); httpService.url = urlstring; httpService.addEventListener(ResultEvent.RESULT, onResult); httpService.addEventListener(FaultEvent.FAULT, onFault); httpService.send(); } function onResult(e:ResultEvent):void{ CursorManager.removeBusyCursor(); //BusyIndicator.visible = false; if( e && e.result){ try{ var results : ArrayCollection; if(e.result.FeatureCollection.featureMember == null) { return; } else if(e.result.FeatureCollection.featureMember is ObjectProxy) { results = new ArrayCollection([e.result.FeatureCollection.featureMember]); } else { results = e.result.FeatureCollection.featureMember as ArrayCollection; } if(results && results.length>0){ //GSAdd_LayerName = String(e.result.FeatureCollection["schemaLocation"]); for each(var _LayerName : Object in e.result.FeatureCollection) { if(_LayerName is String){ var schemaLocation:String = String(_LayerName); if(schemaLocation.indexOf("typeName") > 0){ schemaLocation = schemaLocation.substr(schemaLocation.indexOf("typeName")); schemaLocation = schemaLocation.substr(0, schemaLocation.indexOf(" ")); //"typeName=EGIS%3Alayer_eco_17y" GSAdd_LayerName = schemaLocation.substr(schemaLocation.indexOf("%3A")+3); } } } if(!GSAdd_LayerName){ GSAdd_LayerName = GS_LayerName; } if(GSAdd_LayerName){ var _Result :FeatureSet = toFeatures( results ); Out_Result(_Result); } } } catch( resultError :Error){ } } } function onFault(e:FaultEvent):void{ CursorManager.removeBusyCursor(); //BusyIndicator.visible = false; } //////////////////////////////////////////////////////////////////////////////////////////////////// function toFeatures( results : ArrayCollection ) :FeatureSet{ var featureSet :FeatureSet = new FeatureSet(); var features :ArrayCollection = new ArrayCollection(); var attributes :ArrayCollection = new ArrayCollection(); var aliases :Object = new Object(); for each(var featureMember : Object in results) { try{ var graphic :Graphic = new Graphic; graphic.attributes = new Object(); graphic.attributes.GML_FEATURE_ID = String(featureMember[GSAdd_LayerName].fid); graphic.attributes.objectid = String(featureMember[GSAdd_LayerName].objectid); graphic.attributes.objName = String(featureMember[GSAdd_LayerName].생태경관); graphic.attributes.inxnum = String(featureMember[GSAdd_LayerName].inxnum); graphic.attributes.inxname = String(featureMember[GSAdd_LayerName].inxname); graphic.attributes.objValue = String(featureMember[GSAdd_LayerName].생태자연도); //if(!graphic.attributes.objValue)graphic.attributes.objValue = String(featureMember[GSAdd_LayerName].식생평가); createGeometry( graphic, featureMember[GSAdd_LayerName]); if(graphic && graphic.geometry){ features.addItem( graphic ); } } catch (err:Error) { } } featureSet.features = features.source; featureSet.fieldAliases = aliases; return featureSet; } function createGeometry(graphic :Graphic, geometry:Object) :void{ var polygon :Polygon = null; try{ var shape:Object = geometry.geom; if(!shape)shape = geometry.the_geom; // var MultiPolygon:Object = shape.MultiPolygon; var polygonMember:Object = MultiPolygon.polygonMember; var PolygonObject:Object; polygon = new Polygon(); if(!PolygonObject && polygonMember is ArrayCollection){ for( var i :int = 0; i < polygonMember.length; i++){ PolygonObject = polygonMember[i].Polygon; polygon = createRing(polygon, PolygonObject); } }else{ PolygonObject = polygonMember.Polygon; polygon = createRing(polygon, PolygonObject); } } catch (err:Error) { } graphic.geometry = polygon; } function createRing(polygon :Polygon, PolygonObject:Object) :Polygon{ var outerBoundaryIs:Object = PolygonObject.outerBoundaryIs; var LinearRing:Object = outerBoundaryIs.LinearRing; var coordinates:String = String(LinearRing.coordinates); var coords :Array = coordinates.split( " " ); var points :Array = new Array(); for( var i :int = 0; i < coords.length; i++){ var PointXY :Array = coords[i].split( "," ); points.push( new MapPoint( PointXY[0], PointXY[1]) ); } polygon.addRing(points); return polygon; } function Out_Result(featureSet:FeatureSet):void{ CursorManager.removeBusyCursor(); //BusyIndicator.visible = false; if (featureSet.features.length > 0){ var One_graphic:Graphic = featureSet.features[0]; //표시할 레이어 초기화 var myGraphicsLayer:GraphicsLayer = mainmap.getLayer(sLayerName) as GraphicsLayer; if (!myGraphicsLayer){ myGraphicsLayer = new GraphicsLayer(); myGraphicsLayer.id = sLayerName; myGraphicsLayer.name = "hiddenLayer_" + sLayerName; mainmap.reorderLayer(myGraphicsLayer.id, GET_LayerOrder("drawGraphicsLayer")); mainmap.addLayer(myGraphicsLayer); } myGraphicsLayer.clear(); //심볼표시 var myGraphicPoint:Graphic = new Graphic(); myGraphicPoint.geometry = mapPoint; myGraphicPoint.symbol = new PictureMarkerSymbol(_icon_ipin, 30, 30); var F_nm:String = (One_graphic.attributes["objName"]); var inxname:String = (One_graphic.attributes["inxname"]); var F_Value:String = (One_graphic.attributes["objValue"]); if(F_Value == "0") F_Value = "별도관리지역"; else F_Value = F_Value + " 등급"; var _ObjData:String = "[생태자연도]" + "\n" + "생태자연도 : " + F_Value; if(inxname != "undefined")_ObjData += ("\n" + "지역 : " + inxname); if(F_nm != "undefined")_ObjData += ("\n" + "생태경관 : " + F_nm); var _attributes :Object = new Object(); _attributes["NAME"] = _ObjData; var _toolTip:String = _ObjData; One_graphic.toolTip = _toolTip; One_graphic.attributes = _attributes; myGraphicsLayer.add(One_graphic); myGraphicPoint.toolTip = _toolTip; myGraphicPoint.attributes = _attributes; myGraphicsLayer.add(myGraphicPoint); //onGlowObjOne(myGraphicPoint, 3); var contentNavigator:ContentNavigator = new ContentNavigator(); contentNavigator.dataProvider = new ArrayList([ myGraphicPoint ]); mainmap.infoWindowContent = contentNavigator; mainmap.infoWindow.show(myGraphicPoint.geometry as MapPoint); } } } |
|