protected function MainMap_mapClickHandler(event:MapMouseEvent):void { var identifyParams:IdentifyParameters = new IdentifyParameters(); var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPointSymbol); identifyParams.returnGeometry = true; identifyParams.tolerance = 5; identifyParams.width = MainMap.width; identifyParams.height = MainMap.height; identifyParams.geometry = event.mapPoint; identifyParams.mapExtent = MainMap.extent; identifyParams.spatialReference = MainMap.spatialReference; identifyParams.layerIds = layerLIS.visibleLayers.source; //replace this with your layerID identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL; clickGraphicsLayer.clear(); MainMap.infoWindow.hide(); graphicsLayer.clear(); cursorManager.setBusyCursor(); identifyTask.url = layerLIS.url; //replace this with your layer URL identifyTask.execute(identifyParams, new AsyncResponder(resultFunction, faultFunction, clickGraphic)); function resultFunction(results:Array, clickGraphic:Graphic):void { var myInfoRenderer:InfoRenderer = new InfoRenderer; var mapPoint:MapPoint = MapPoint(clickGraphic.geometry); var point:Point = MainMap.toScreen(mapPoint); if (results && results.length > 0) { var oldLayer:Number = -1; var resultsArray:Array = []; var result:IdentifyResult; var resultGraphic:Graphic; var tab:TabNavigator = new TabNavigator(); var newVBox:VBox = new VBox; var newVBoxDG:VBox = new VBox; var newText:Text = new Text; var newDG:DataGrid = new DataGrid; var graphic:Graphic; clickGraphicsLayer.add(clickGraphic); result = results[0]; oldLayer = result.layerId; resultsArray.push(result.feature.attributes); newText = new Text; newText.text = result.layerName; graphic = result.feature; graphic.alpha = 0.3; graphicsLayer.add(graphic); tab.width = 400; tab.height = 230; // for (var i:int = 1; i < results.length; i++) // { // result = results; // graphic = new Graphic; // graphic = result.feature; // graphic.alpha = 0.3; // graphicsLayer.add(graphic); // if (result.layerId == oldLayer) // { // resultsArray.push(result.feature.attributes); // } // else // { // newDG = new DataGrid; // newVBox = new VBox; // newDG.dataProvider = resultsArray; // // newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true); // newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0 ,true); // newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true); // // newVBox.addElement(newText); // newVBox.addElement(newDG); // newVBox.label = oldLayer.toString(); // newVBox.label = oldLayer.toString(); // tab.addElement(newVBox); // myInfoRenderer.addElement(tab); // // newText = new Text; // newText.text = result.layerName; // resultsArray = []; // resultsArray.push(result.feature.attributes); // } // oldLayer = result.layerId; // } newVBox = new VBox; newVBoxDG = new VBox; newDG = new DataGrid; newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true); newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0, true); newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true); newVBox.addElement(newText); newDG.dataProvider = resultsArray; newVBox.addElement(newDG); newVBox.label = oldLayer.toString(); tab.addElement(newVBox); myInfoRenderer.addElement(tab); cursorManager.removeBusyCursor(); MainMap.infoWindow.content = myInfoRenderer; MainMap.infoWindow.label = "Results"; MainMap.infoWindow.show(MainMap.toMap(point)); MainMap.infoWindow.addEventListener(Event.CLOSE, infoWindow_Close, false, 0, true); } } } protected function newDG_ItemRollOut(event:ListEvent):void { graphicLayer.clear(); } protected function newDG_ItemRollOver(event:ListEvent):void { var highlightedGraphic:Graphic = findGraphicByAttribute(event.itemRenderer.data); var glowFill:SimpleFillSymbol = new SimpleFillSymbol; var glower:AnimateFilter = new AnimateFilter(highlightedGraphic,glow); glower.motionPaths = kf; glower.duration = 500; glower.play(); } protected function faultFunction(error:Object, token:Object = null):void { cursorManager.removeBusyCursor(); Alert.show(error.toString()); } protected function findGraphicByAttribute(attributes:Object):Graphic { for each (var graphic:Graphic in graphicsLayer.graphicProvider) { if (graphic.attributes == attributes) { return graphic; } } return null; }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.