Select to view content in your preferred language

I can't understand the following code for ArcGIS Flex

494
1
Jump to solution
07-23-2013 05:21 PM
wjiarao
New Contributor
When clicking a map, a infowindow showing the latitude and lontitude of map, is the function of the following code, depending on
onMapClick function namely:

private function onMapClick(event:MapMouseEvent):void
   {
    var content:Object = {};
    content.wm = event.mapPoint;
    ldr.data = content;
    ldr.label = "Lat-Lon??";
    myMap.infoWindow.show(event.mapPoint);
   }


but I can't understand the function as follows:
1). Define an empty object content, but why event.mapPoint equal to content.wm, what's wm stands for?
2). When perform myMap.infoWindow.show(event.mapPoint), the information of lat-lon will display in a infowindow, why define the content Object? Is it necessary?

Hopefully someone who knows can tell me ,thanks very much.


See the following code:


<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Identify Features on the Map" xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
  <![CDATA[
  
  
   import com.esri.ags.Graphic;
   import com.esri.ags.components.ContentNavigator;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Extent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.utils.WebMercatorUtil;
  
   import mx.collections.ArrayList;  
 
   [Bindable]
   [Embed(source="assets/i_otherservice.png")]
   public var UserIcon:Class;
  
   private function onMapClick(event:MapMouseEvent):void
   {
    var content:Object = {};
    content.wm = event.mapPoint;
    ldr.data = content;
    ldr.label = "Lat-Lon??";
    myMap.infoWindow.show(event.mapPoint);
   }
  ]]>
</fx:Script>

<s:RichEditableText x="200" y="40" editable="false" backgroundColor="aqua"
      text='xmin="{myMap.extent.xmin.toFixed(5)}"    ymin="{myMap.extent.ymin.toFixed(5)}"
      xmax="{myMap.extent.xmax.toFixed(5)}"    
      ymax="{myMap.extent.ymax.toFixed(5)}"
      wkid="{myMap.spatialReference.wkid}"
      level="{myMap.level}"
      current scale=1:"{myMap.scale}"' />

<esri:Map id="myMap" x="300" y="100" height="500" width="700" mapClick="onMapClick(event)"> 
  <esri:infoWindowContent>
   <esri:LabelDataRenderer  accentColor="red" id="ldr" color="green">
    <esri:layout>
     <s:VerticalLayout paddingBottom="5"
           paddingLeft="5"
           paddingRight="5"
           paddingTop="5"/>
    </esri:layout>
    <s:Label text="Lontitude: {ldr.data.wm.x.toFixed(5)}"/>
    <s:Label text="Latitude: {ldr.data.wm.y.toFixed(5)}"/>
   </esri:LabelDataRenderer>
  </esri:infoWindowContent>
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Honored Contributor
Wjia,

Content is just an empty object and wm is assigned as an attribute to that object (does not really matter if it stands for any thing my guess is Web Mercator). The attributes of the event are then assigned to the wm attribute of content. These are then passed to ldr which is the label data renderer.

Regards

Anthony

View solution in original post

0 Kudos
1 Reply
AnthonyGiles
Honored Contributor
Wjia,

Content is just an empty object and wm is assigned as an attribute to that object (does not really matter if it stands for any thing my guess is Web Mercator). The attributes of the event are then assigned to the wm attribute of content. These are then passed to ldr which is the label data renderer.

Regards

Anthony
0 Kudos