Select to view content in your preferred language

Identify features to new view in mobile app

962
3
08-22-2011 04:05 AM
raffia
by
Deactivated User
Dear all;

Am using Flex 4.5.1 on Win XP, mobile project. A simple identify function that identifies polygon landmarks in the map and send the identify results to a new view, and it is driving me crazy. To send variables to a new view, I used this technique
http://devgirl.org/2011/08/09/flex-mobile-development-passing-data-between-tabs-part-2-includes-sour...

Then modified it every which way to no avail.

Main App relevant code:

   import model.landmarks;
   
   import views.landmarkDetailsWindow;
   
   [Bindable]
   public var landmarksVar:landmarks = new landmarks();



landmarks.as code:

package model
{
 [Bindable]
 public class landmarks
 { 
  public var type:String;
  public var name:String;
  public function landmarks()
  {  
   this.type = type;
   this.name = name;
  }
 }
}



First View relevant code, where the identify happens:
   [Bindable]private var lastIdentifyResultGraphic:Graphic;
   var clickGraphic;
   private function identifyClickHandeler(event:MapMouseEvent):void
   {

    myMap.extent = new Extent(31.192271, 30.043800, 31.219662, 30.073615, null);
    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;    


    
   identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
   }   
   
   
   private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
   {
    
    var identWinVar:DE_Mobile_App = parentDocument as DE_Mobile_App;
    landmarksVar = identWinVar.landmarksVar;


     if(result.layerName == "Landmarks")
     {
     
//////The following lines is where I attempt to send the data identified (Type and Name) to the second view
     landmarksVar.type =result.feature.attributes["Type"].toString(); 
     landmarksVar.name =result.feature.attributes["Name"].toString(); 
     navigator.pushView(landmarkDetailsWindow); 


     }
      

    }
   }
   
   private function myFaultFunction():void
   {
   }



 <esri:Map id="myMap">
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer 
          url="http://arcgis2.roktech.net/ArcGIS/rest/services/DigitalEg/English_Layered/MapServer"/>
  
 </esri:Map>

 <s:Button label="Ident" click="myMap.addEventListener(MapMouseEvent.MAP_CLICK, identifyClickHandeler)"/>



Code for landmarkDetailsWindow:
 <fx:Script>
  <![CDATA[
   import model.landmarks;
   [Bindable]
   public var landmarksVar:landmarks ;
  ]]>
 </fx:Script>

 <s:VGroup>
  

 <s:Label  text="Type:"/>
 <s:Label  text="{landmarksVar.type}"/>
 <s:Label  text="Name:"/>
 <s:Label  text="{landmarksVar.name}"/>  
 </s:VGroup>



When debugging, you see that identWinVar.landmarksVar.type and .name are assigned the proper values when a landmark polygon is identified...

I also tried replacing this line
landmarksVar.type =result.feature.attributes["Type"].toString(); 

with
identWinVar.landmarksVar.type =result.feature.attributes["Type"].toString(); 

to no avail. Thanks in advance.
Tags (2)
0 Kudos
3 Replies
DarinaTchountcheva
Frequent Contributor
Hi Raffi,

My Flex is getting kind of rusty, and you know I haven't done anything mobile, but here are some links that might help  you:

http://help.adobe.com/en_US/flex/mobileapps/WSa122979b4619725672e48c412a3e152164-7fff.html#WSe11993e...

http://cookbooks.adobe.com/post_Passing_data_between_Views-18854.html

😄

P.S. I just open your link, you are using the second approach. Have you tried the first (which is explained in the links above):

http://devgirl.org/2011/08/09/flex-mobile-development-passing-data-between-tabs-part-1-includes-sour...
0 Kudos
DarinaTchountcheva
Frequent Contributor
Raffi,

In the links above, I see a second parameter to the pushView method, which is the data that you want to pass.

Maybe, this what you are missing.
Another link:

http://www.unitedmindset.com/jonbcampos/2010/10/25/flex-4-5-mobile-development-post-burrito/

Good Luck!
0 Kudos
raffia
by
Deactivated User
Thank you very much, as always, Darina 🙂

Raffi,

In the links above, I see a second parameter to the pushView method, which is the data that you want to pass.

Maybe, this what you are missing.
Another link:

http://www.unitedmindset.com/jonbcampos/2010/10/25/flex-4-5-mobile-development-post-burrito/

Good Luck!
0 Kudos