Select to view content in your preferred language

Flex API 1.3 map extent binding

594
4
10-28-2010 05:51 AM
SteveLi
Emerging Contributor
I have a custom map component
public class myMap extends Map and I bind the extent to a model:
this.extent = MapData.instance.ext;

I update MapData.instance.ext in my controller, but map doesn't change its extent.

I have other map attributes bound to the same model, they all work fine, only extent I couldn't make work.

Thanks for any insights.
Tags (2)
0 Kudos
4 Replies
Drew
by
Frequent Contributor
is this.extent set to be bindable ?
[Bindable]
public var foo:String;



EDIT
-------------------
Actually, Rethinking your problem�?�.

I guess this.extent is coming from Map itself and is not a custom property.. so it must be bindable already�?�.. hummm
0 Kudos
Drew
by
Frequent Contributor
I did a few test and the only way (in code) that I could do it was like below�?�

I modified it to match your code so there could be some modifications need.. If anything it will give you some clues


override public function myMap()
  {
   super();
   this.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
  }
  
  private function onCreationComplete(event:FlexEvent):void
  {
   BindingUtils.bindSetter(setterFunc, MapData.instance, "ext");
  }
  
  private function setterFunc(ext:Extent):void 
  {
   this.extent= ext;
      } 

0 Kudos
SteveLi
Emerging Contributor
Thanks for the quick response.

Somehow it's still not working for me through a testing button:
MapData.instance.ext = new Extent(-8560018, 3812354, 333583, 8215127, new SpatialReference(102100));

No change on the map.

I did a few test and the only way (in code) that I could do it was like below�?�

I modified it to match your code so there could be some modifications need.. If anything it will give you some clues


override public function myMap()
  {
   super();
   this.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
  }
  
  private function onCreationComplete(event:FlexEvent):void
  {
   BindingUtils.bindSetter(setterFunc, MapData.instance, "ext");
  }
  
  private function setterFunc(ext:Extent):void 
  {
   this.extent= ext;
      } 

0 Kudos
Drew
by
Frequent Contributor
another way is to bind in the markup

<ns1:myMap extent="{MapData.instance.ext}"  width="800" height="250">
     <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
    </ns1:myMap>
0 Kudos