Select to view content in your preferred language

Insert the Identify Sample into the Index.mxml

2551
8
03-03-2011 01:19 AM
ThomasBuchmann1
Deactivated User
Hello,

I'm trying to add the IdentifySample from the sample applications to my Index.
But where do i have to put the "map"-information from the identifysample?

Here's what i have:

 <esri:Map id="myMap"
     mapClick="mapClickHandler(event)"
     openHandCursorVisible="false">
  <esri:extent>
   <esri:WebMercatorExtent minlon="-120" minlat="30" maxlon="-100" maxlat="50"/>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>
  <esri:GraphicsLayer id="clickGraphicsLayer"/>
 </esri:Map>

 
 <viewer:ViewerContainer>
  <viewer:configManager>
   <managers:ConfigManager/>
  </viewer:configManager>
  <viewer:dataManager>
   <managers:DataManager/>
  </viewer:dataManager>
  <viewer:mapManager>
   <managers:MapManager/>
  </viewer:mapManager>
  <viewer:uiManager>
   <managers:UIManager/>
  </viewer:uiManager>
  <viewer:widgetManager>
   <managers:WidgetManager/>
  </viewer:widgetManager>
 </viewer:ViewerContainer>


The part above (esri:Map) is from the identifysample, and the other (viewer:xxx) from the index.mxml.

I need your help, please...

Regards,
thombu
Tags (2)
0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus
Thomas,

   I am wondering why you are trying this when there is an identify widget???
0 Kudos
ThomasBuchmann1
Deactivated User
Hi Robert,

because i want an identify Tool that always can be used without activation by use of a widget.
Perhaps you're right and i should try to solve the problem with a widget.

What i want is just a simple Identify Tool like it is in the named sample:
-without a sperate window
- and features are marked after the click

How do i create such a widget? Is it a good idea to try to bring the code from the sample into a widget?

Thanks for your answer,
thomas
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Thomas,

   Are you interested in just one or two layers or are you wanting to be able to id everything in the map just no interface?
0 Kudos
ThomasBuchmann1
Deactivated User
I want to identify just one or two layers but no interface.
The result should be shown in a "InfoPopUp" as in the IdentifySample.

The ID-Tool must not necessarily always be available. It would also be nice to start it with a Icon.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Thomas,

   Seems how your requirements are very specific I would go back to integrating the Identify Sample. You  should probably start with this tutorial video http://resources.arcgis.com/gallery/video/arcgis-api-for-flex/details?entryID=870F152C-1422-2418-A01... on how to create a widget. Each widget has access to the map component and you can have widgets that have no UI.
0 Kudos
ThomasBuchmann1
Deactivated User
Seems how your requirements are very specific I would go back to integrating the Identify Sample.


What do you mean? integrating the IdentifySample into the Index.mxml or into a widget?
Thanks for the link. I've already wachted it.
I'm new in Flex so i don't think that i'm able to create a widget from zero.

Is it possible to easily integrate the applications-code into a widget?

thanks for your help!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Thomas,

   Going the New Widget route would be best. Yes you could take a majority of the sample code and use that in a widget, but you would be talking about creating a new widget like the video discusses. If you opt against that route than you need to look att adding the identify sample code to the MapManager not the index.mxml.
0 Kudos
ThomasBuchmann1
Deactivated User
Thanks for the advice, Robert.
I think i give it up. I have to less knowhow to create this widget.

That's what i've done:
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:esri="http://www.esri.com/2008/ags"
                   xmlns:viewer="com.esri.viewer.*">

 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.symbols.InfoSymbol;
   import com.esri.ags.tasks.supportClasses.IdentifyParameters;
   import com.esri.ags.tasks.supportClasses.IdentifyResult;
   
   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
   
   [Bindable]
   private var lastIdentifyResultGraphic:Graphic;
   
   private function mapClickHandler(event:MapMouseEvent):void
   {
    clickGraphicsLayer.clear();
    
    var identifyParams:IdentifyParameters = new IdentifyParameters();
    identifyParams.returnGeometry = true;
    identifyParams.tolerance = 3;
    identifyParams.width = myMap.width;
    identifyParams.height = myMap.height;
    identifyParams.geometry = event.mapPoint;
    identifyParams.mapExtent = myMap.extent;
    identifyParams.spatialReference = myMap.spatialReference;
    
    var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
    clickGraphicsLayer.add(clickGraphic);
    
    identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
   }
   
   private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
   {
    if (results && results.length > 0)
    {
     var result:IdentifyResult = results[0];
     var resultGraphic:Graphic = result.feature;
     switch (resultGraphic.geometry.type)
     {
      case Geometry.MAPPOINT:
      {
       resultGraphic.symbol = smsIdentify;
       break;
      }
      case Geometry.POLYLINE:
      {
       resultGraphic.symbol = slsIdentify;
       break;
      }
      case Geometry.POLYGON:
      {
       resultGraphic.symbol = sfsIdentify;
       break;
      }
     }
     lastIdentifyResultGraphic = resultGraphic;
     
     // update clickGraphic (from mouse click to returned feature)
     clickGraphic.symbol = new InfoSymbol(); // use default renderer
     clickGraphic.attributes = resultGraphic.attributes;
    }
   }
   
   private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
   {
    Alert.show(String(error), "Identify Error");
   }
  ]]>
 </fx:Script>
 
 
 <fx:Declarations>
  <!-- Symbol for where the user clicked -->
  <esri:SimpleMarkerSymbol id="clickPtSym"
         color="0x000000"
         alpha="0.5"
         size="12"
         style="circle"/>
  
  <!-- Symbol for Identify Result as Polyline -->
  <esri:SimpleLineSymbol id="slsIdentify"
          width="2"
          alpha="1"
          color="0x00FF00"
          style="solid"/>
  
  <!-- Symbol for Identify Result as Point -->
  <esri:SimpleMarkerSymbol id="smsIdentify"
         color="0x00FF00"
         size="15"
         style="diamond"/>
  
  <!-- Symbol for Identify Result as Polygon -->
  <esri:SimpleFillSymbol id="sfsIdentify"/>
  
  <!-- Identify Task -->
  <esri:IdentifyTask id="identifyTask"
         concurrency="last"
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/>
 </fx:Declarations>
 
 
 <esri:Map  id="myMap"
      mapClick="mapClickHandler(event)"
     openHandCursorVisible="false">
  <esri:extent>
   <esri:WebMercatorExtent minlon="-120" minlat="30" maxlon="-100" maxlat="50"/>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>
  <esri:GraphicsLayer id="clickGraphicsLayer"/>
 </esri:Map>
 
</viewer:BaseWidget>


Here it is again, the "esri:map" part. How do i have to change it to run the widget?
0 Kudos