Points As Graphic Layer - Display popups programmatically

710
3
12-06-2013 09:13 AM
LuisMartinez3
New Contributor II
I am using the sample code from the Display popups programmatically sample. However, i changed my graphics from polygons to points and made changes to the code to reflect that in the map display and in the maps Table of Contents. Everything works well except for the "Zoom To" from selecting a user selected site from the Table of Contents (Not the Button). This is a very first rough draft of the application http://www.scpgis.com/BMAP/Copyofbmap.html. Anyone have any idea what I am doing wrong? I thought it was simple but it got to the point where Im done banging my head over trying to resolve this...thanks in advance for takin a glance. Here is some of the code...

</fx:Script>
.
.
protected function queryTask_executeCompleteHandler(event:QueryEvent):void
{ if (event.featureSet.features)
{ statesGraphicsLayer.graphicProvider = event.featureSet.features;
statesList.dataProvider = new ArrayList(event.featureSet.features);
map.extent = GraphicUtil.getGraphicsExtent(event.featureSet.features);
}
}
protected function esriService_faultHandler(event:FaultEvent):void
{ Alert.show("Error: " + event.fault.faultString, "Error code: " + event.fault.faultCode);
}
protected function statesList_changeHandler(event:IndexChangeEvent):void
{ // Get the current graphic from the selectedItem in the List
var currentGraphic:Graphic = List(event.currentTarget).selectedItem as Graphic;
var mapPoint:MapPoint = currentGraphic.geometry.extent.center;
contentNavigator.dataProvider = new ArrayList([ currentGraphic ]);
// Put the ContentNavigator in the info window.
map.infoWindowContent = contentNavigator;
map.zoomTo(currentGraphic.geometry);
map.infoWindow.show(mapPoint);
}
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.layers.TiledMapServiceLayer;
import mx.events.FlexEvent;
private function layerShowHandler(event:FlexEvent):void
{var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;
map.lods = tiledLayer.tileInfo.lods;}
]]>
</fx:Script>

<fx:Declarations>
<esri:NavigationTool id="navTool" map="{map}"/>
<esri:Query id="query"
outFields="[Site_Name, Site_Addre,SiteID]"
outSpatialReference="{map.spatialReference}"
returnGeometry="true"
where="1=1"/>
<esri:QueryTask id="queryTask"
executeComplete="queryTask_executeCompleteHandler(event)"
fault="esriService_faultHandler(event)"showBusyCursor="true"
url="http://65.82.52.71/webmaps/rest/services/BMAP/MapServer/0"/>
</fx:Declarations>

Here is where I create the point graphics layer...
<esri:GraphicsLayer id="statesGraphicsLayer">
<esri:symbol>
<esri:SimpleMarkerSymbol id="defaultsym"
color="0xFF0000"
size="11"
alpha="0.8"
style="circle">
<esri:SimpleLineSymbol
color="0x000000"
width="1"
alpha="0.5"
style="solid" />
</esri:SimpleMarkerSymbol>
</esri:symbol>
</esri:GraphicsLayer>

Here is where I create the Table of Contents...
<s:Group width="200" height="100%"right="0" top="0">
<s:Rect left="0" right="0" top="0" bottom="0"
radiusX="5"
radiusY="5">
<s:fill>
<s:SolidColor color="0xd6d7d6"/>
</s:fill>
</s:Rect>
<s:Rect left="4" right="4" top="4" bottom="4"
radiusX="5"
radiusY="5">
<s:fill>
<s:SolidColor color="0xd6d7d6"/>
</s:fill>
</s:Rect>
<s:VGroup width="100%" height="100%"
paddingBottom="5"
paddingLeft="5"
paddingRight="5"
paddingTop="5"
verticalAlign="middle">
<s:Label fontSize="12" text="Site Name"/>
<!--When we click on the item, which is an API Graphic object fire the change event so we can get the graphic.-->
<s:List id="statesList"
width="100%" height="90%"
change="statesList_changeHandler(event)">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:states>
<s:State name="normal"/>
<s:State name="hovered"/>
<s:State name="selected"/>
</s:states>
<s:Label height="20"
left="5"
fontWeight.selected="bold"
fontSize="10"
text="{data.attributes.Site_Name}"
verticalAlign="middle"/>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
</s:VGroup>
</s:Group>
Tags (2)
0 Kudos
3 Replies
BenjaminMercier
New Contributor III
Hi,

The problem is that a point layer couldn't have any extent I guess.

You should try that:
   var mapPoint:MapPoint = currentGraphic.geometry as MapPoint;


because your currentGraphic is a type of esriPointGeometry
Hope it helps,

Ben
0 Kudos
LuisMartinez3
New Contributor II
Thanks Benjamin, I will give that a shot...it makes sense now...I spent two days fumbling with this and didnt even see the graphic as point type....whew. Thanks again.
Luis4018
0 Kudos
AronHarris
New Contributor II
I am trying to do the same thing could you I get a copy of your code
0 Kudos