Select to view content in your preferred language

using PopUpInfo for a layer with dynamic join

3499
7
03-04-2013 12:42 PM
xiaowenyang
Deactivated User
I've added a layer with dynamic join -- very similiar to (http://resources.arcgis.com/en/help/flex-api/samples/index.html#/DynamicLayerInfo_JoinDataSource/01n...). However, when I try to use PopUpInfo to show the field value, even though I tried different combination of layername.fieldname or fieldname, I still got no luck. Can anyone guide me this?


Thank you in advance.

Xiaowen
Tags (2)
0 Kudos
7 Replies
AnthonyGiles
Honored Contributor
Xiaowen,

You will need to supply a little more info for people to trouble shoot, like your popup config and either a screen shot of your rest URL or a link to the rest endpoint if it is public.

One thing to remember is that flex is case sensitive

Regards

Anthony
0 Kudos
xiaowenyang
Deactivated User
Hi Anthony,
Thank you for your reply. Here's my set up
My spatial table is
http://23.21.106.101:6080/arcgis/rest/services/AdminBoundary/MapServer
This table is linked to another table by code, the join relationship is very similar to below

{"source": {
"dataSource": {
  "workspaceId": "MyPostgreSQL",
  "dataSourceName": "user1362603115943",
  "type": "table"
},
"type": "dataLayer"
}}

So, I can add a layer like (http://23.21.106.101:6080/arcgis/rest/services/AdminBoundary/MapServer/dynamicLayer?layer=%7B%22sour...) into my application by program. Then I want to add popup info for this new created layer by the mudal below. However, even though this code works for other regular(no dynamic join layer), I can not make it work for this dynamic layer with dynamic join.


private function configurePopUp(indicator:Object, layerID:Number):void{
    /**showing the pop up info for indicator layer*/
    var popUpInfo:PopUpInfo = new PopUpInfo(); 
    var pFieldInfos:Array = [];
    var pFieldInfo:PopUpFieldInfo = new PopUpFieldInfo();
    //pFieldInfo.fieldName ="sdegdb." + String(indicator.viewName).toLowerCase()+ "." + indicator.fldName;
    //pFieldInfo.fieldName = "newtam6";
    //pFieldInfo.fieldName = String( indicator.viewName).substr(7, (String( indicator.viewName).length-7)) + "." + indicator.fldName;
    pFieldInfo.fieldName = "newtam6";
    pFieldInfos.push(pFieldInfo);  
    popUpInfo.title =  indicator.indicatorStr;
    popUpInfo.popUpFieldInfos = pFieldInfos;
    //popUpInfo.description = "indicator is {sdegdb." + indicator.viewName+ "." + indicator.fldName+ "}"; 
    Alert.show("indicator is" + pFieldInfo.fieldName + "     " + layerID.toString());
   
    var popUpRenderer:ClassFactory = new ClassFactory(PopUpRenderer);
    popUpRenderer.properties = {popUpInfo: popUpInfo };     
    var layerInfoWindowRenderer:LayerInfoWindowRenderer= new LayerInfoWindowRenderer();
    layerInfoWindowRenderer.layerId = layerID; 
    var infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer);
    infoWindowRenderer.properties = { popUpInfo: popUpInfo };
    var arrLayerInfoWindowRenderer:Array = [];
    arrLayerInfoWindowRenderer.push(popUpRenderer);
    InDynMapLyr.layerInfoWindowRenderers = arrLayerInfoWindowRenderer; 
   }

Thank you for your help!
0 Kudos
AnthonyGiles
Honored Contributor
Have you tried:

sdegdb.editor.User1362603115943.newtam6

As your field name

Regards

Anthony
0 Kudos
xiaowenyang
Deactivated User
I've tried the following options, none of them works
sdegdb.editor.User1362628252032.newtam6  
sdegdb.editor.User1362628252032.max_p_ch14nou1990
max_p_ch14nou1990
User1362628252032.max_p_ch14nou1990 

Is there any combination that I missed?


Thanks

Xiaowen
0 Kudos
AnthonyGiles
Honored Contributor
What about just dropping the first bit:

editor.User1362603115943.newtam6

Regards

Anthony
0 Kudos
xiaowenyang
Deactivated User
Hello Anthony,
I modified the sample mxml code to figure out the issue. Even though <s:Label text = "data: {ObjectUtil.toString(data)}"/>

can successfully display the data, <s:Label text="ID: { data.ancestry.State}"/> won't show anything at all. I am wondering how can I define popupinfo by actionscript to show something like ObjectUtil.toString(data)?

Thanks





<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2010-2011 ESRI

    All rights reserved under the copyright laws of the United States
    and applicable international laws, treaties, and conventions.

    You may freely redistribute and use this sample code, with or
    without modification, provided you include the original copyright
    notice and use restrictions.

    See use restrictions in use_restrictions.txt.
-->
<s:Application 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"
               pageTitle="Dynamic layer - FeatureLayer">
    <!--
    Description:
    This sample demonstrates how to create a FeatureLayer using a
    dynamic layer (lakes) from a service that has a registered workspace.
    This demonstrates one of the new features in ArcGIS 10.1; adding layers
    on the fly through a dynamic workspace, which allows
    developers to add layers on the fly that do not exist in a service.
    The ArcGIS map service needs to have the Dynamic Layers capability turned on,
    and it also needs a registered workspace.  The registered workspace will be of
    type (Database, File Geodatabase, Shapefile, or Raster), and once registered then
    you can access layers within the workspace.

    Note:
    This sample adds the layer as a client-side FeatureLayer, whereas the
    "Dynamic Workspace" sample uses the server-side method to add the layer
    to the map service.  This sample uses client-side methods to symbolize
    the features, whereas the other sample uses server-side methods to add
    the layer and symbolize the features on the server.

    Documentation:
    For more information, see the API documentation.
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/FeatureLayer.html
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/FeatureLayer.html#source
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/renderers/SimpleRenderer.html
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/LayerDataSour...
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/LayerDataSour...
    http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/TableDataSour...

    ArcGIS REST API documentation:
    http://resources.arcgis.com/en/help/rest/apiref/dynamicLayer.html
    http://resources.arcgis.com/en/help/rest/apiref/dataSource.html
    http://resources.arcgis.com/en/help/rest/apiref/layerSource.html

    ArcGIS for Server documentation:
    http://resources.arcgis.com/en/help/main/10.1/index.html#/About_dynamic_layers/0154000004zv000000/
    -->

    <fx:Style>
        @namespace esri "http://www.esri.com/2008/ags";

        esri|ContentNavigator
        {
            headerBackgroundColor: #0080FF;
        }
    </fx:Style>

    <fx:Script>
        <![CDATA[
   import com.esri.ags.utils.JSONUtil;
  
   import mx.utils.ObjectUtil;

        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <!-- Lakes Layer Dynamic Layer Info -->
        <esri:LayerDataSource id="lakesLayerDataSource">
            <!-- FeatureClass within the Dynamic Workspace (follow the link in the sample description for more information on dynamic workspaces) -->
            <esri:TableDataSource dataSourceName="ss6.gdb.Lakes" workspaceId="MyDatabaseWorkspaceIDSSR2"/>
        </esri:LayerDataSource>
    </fx:Declarations>

<s:controlBarContent>
  <s:RichEditableText width="100%" editable="false">
   This sample demonstrates how to create a dynamic join with a layer
   (states) in a map service to a table (ancestry) in a dynamic
   workspace.  Click a record to see more information about a given state,
   <s:a href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/dynamicLayer?layer={JSONUtil.encode({ source: ancestryLayerDataSource })}" target="_blank">view the ancestry table</s:a>, or
   <s:a href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3" target="_blank">view the states layer</s:a>.
  </s:RichEditableText>
</s:controlBarContent>

<esri:Map id="map">
  <esri:extent>
   <esri:Extent xmin="-13988193" ymin="3016128" xmax="-7432953" ymax="6450291">
    <esri:SpatialReference wkid="102100"/>
   </esri:Extent>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"/>

  <esri:ArcGISDynamicMapServiceLayer id="censusMapServiceLayer" name="Ancestry by State"
             url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer">
   <esri:dynamicLayerInfos>
    <!-- states layer id in the census map service -->
    <esri:DynamicLayerInfo layerId="3" defaultVisibility="true">
     <esri:LayerDataSource id="dynamicLayerSource">
      <esri:JoinDataSource joinType="esriLeftOuterJoin"
            leftTableKey="STATE_NAME"
            rightTableKey="State">
       <esri:leftTableSource>
        <!-- states layer id in the census map service -->
        <esri:LayerMapSource id="statesLayerMapSource" mapLayerId="3"/>
       </esri:leftTableSource>
       <esri:rightTableSource>
        <esri:LayerDataSource id="ancestryLayerDataSource">
         <!-- Dynamic Workspace (follow the link in the sample description for more information on dynamic workspaces -->
         <!-- table name and workspace id from census map service dynamic workspaces configuration -->
         <esri:TableDataSource dataSourceName="ancestry" workspaceId="CensusFileGDBWorkspaceID"/>
        </esri:LayerDataSource>
       </esri:rightTableSource>
      </esri:JoinDataSource>
     </esri:LayerDataSource>
    </esri:DynamicLayerInfo>
   </esri:dynamicLayerInfos>
  
   <esri:layerInfoWindowRenderers>
    <esri:LayerInfoWindowRenderer layerId="3" >   
     <esri:infoWindowRenderer >
      <fx:Component>
      
       <esri:LabelDataRenderer label=" Details">
        <s:VGroup paddingBottom="5"
            paddingLeft="5"
            paddingRight="5"
            paddingTop="5">
         <fx:Script>
          <![CDATA[
           import mx.utils.ObjectUtil;
          ]]>
         </fx:Script>       
         <s:Label text="ID: { data.ancestry.State}"/>
         <s:Label text="Name: {data.states.ASIAN }"/>
         <s:Label text = "data: {ObjectUtil.toString(data)}"/>
         <!--<s:Label text = "data: {String(ObjectUtil.getClassInfo(data).properties)}"/>-->
        </s:VGroup>
       </esri:LabelDataRenderer>
      </fx:Component>
     </esri:infoWindowRenderer>
    </esri:LayerInfoWindowRenderer>   
    </esri:layerInfoWindowRenderers>
  
  </esri:ArcGISDynamicMapServiceLayer>

 
    </esri:Map>
</s:Application>
0 Kudos
xiaowenyang
Deactivated User
I've figured out the question above for showing field info for dynamic join . Here's the code for labledatarender



<fx:Component>
       <esri:LabelDataRenderer label=" Details">
        <s:VGroup paddingBottom="5"
            paddingLeft="5"
            paddingRight="5"
            paddingTop="5" >
         <fx:Script>
          <![CDATA[
           import mx.utils.ObjectUtil;
           [Bindable]
           var fieldName:String = "ancestry.State";
          ]]>
         </fx:Script>       
         <s:Label text="ID: { data[fieldName]}"/>
         <s:Label text="Name: {data.states.ASIAN }"/>
         <!--<s:Label text = "data: {ObjectUtil.toString(data)}"/>-->
         <!--<s:Label text = "data: {ObjectUtil.toString(ObjectUtil.getClassInfo(data))}"/>-->
        </s:VGroup>
       </esri:LabelDataRenderer>
      </fx:Component>

With this experience, layer with dynamic join should use customized labeldatarender instead of builtin popupinfo for arcgis viewer for flex. The trick is data[fieldName].
0 Kudos