QueryTask AS 쓰기
                                            
 2424 단어  query
                    
protected function myMap_initializeHandler(event:MapEvent):void
            {
                // Query to get the cities under the specified state
                var queryTask:QueryTask = new QueryTask();
                queryTask.url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0";
                queryTask.useAMF = false;
                var query:Query = new Query();
                query.outSpatialReference = myMap.spatialReference;
                query.outFields = [ "CITY_NAME", "AGE_UNDER5", "AGE_5_17", "AGE_18_64", "AGE_65_UP" ];
                query.returnGeometry = true;
                query.where = "STATE_NAME = 'Alaska' AND TYPE = 'city'";
                queryTask.execute(query, new AsyncResponder(onResult, onFault));
                // add the graphic on the map
                function onResult(featureSet:FeatureSet, token:Object = null):void
                {
                    for each (var myGraphic:Graphic in featureSet.features)
                    {
                        myGraphicsLayer.add(myGraphic);
                        // creating an arraycollection from the graphic attriobutes
                        var object:ArrayCollection = new ArrayCollection(
                            [
                            { CITY_NAME: myGraphic.attributes.CITY_NAME, AGE: "Under 5", VALUE: myGraphic.attributes.AGE_UNDER5 },
                            { CITY_NAME: myGraphic.attributes.CITY_NAME, AGE: "Age 5-17", VALUE: myGraphic.attributes.AGE_5_17 },
                            { CITY_NAME: myGraphic.attributes.CITY_NAME, AGE: "Age 18-64", VALUE: myGraphic.attributes.AGE_18_64 },
                            { CITY_NAME: myGraphic.attributes.CITY_NAME, AGE: "65 and up", VALUE: myGraphic.attributes.AGE_65_UP }
                            ]);
                        myGraphic.attributes = object;
                    }
                }
                function onFault(info:Object, token:Object = null):void
                {
                    Alert.show(info.toString());
                }
            }
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
빠른 팁!!!안녕하세요 여러분 👋 요청을 할 때 모든 구성 요소에 동일한 코드를 작성하는 데 정말 지쳤습니다. 나는 일을 단순하게 만들고 싶고 내 생각에 당신도 원할 것입니다. 그런 것들에 대한 팁을 보려면 내 예를 확인하십시오...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.