POST
|
I have modified an example from the user forum (version 1.3 of FLEX) that will let the user draw a polygon and get summary statistics and a chart based on their selection. This works just fine when you have contiguous polygons. However, what if I wanted to compare 3 or counties that are not next to each other? I thought I might be able to modify this to add points (or multipoints). I would then need to have something different as a trigger to know when the user was done adding points (unlike polygon that has a draw end built into it). If I have multiple points, then I'm assuming I would need to loop through each of my points I'd drawn. I can't decide whether I am better off using an identify task instead of the query task I have set for the drawn polygon. This code works now with just polygons for anyone who wants to have another basic charting/datagrid/summary example.
... View more
12-28-2010
08:16 AM
|
0
|
10
|
985
|
POST
|
Now that I've played with it a bit more, it does seem to be listening and responding to extent changes from more than just the original map. Thanks very much and Merry Christmas!
... View more
12-23-2010
04:57 AM
|
0
|
0
|
264
|
POST
|
Thank you very much. I will work with this. I had hoped that I could have any extent change on any map reset the remaining maps. Is this just wishful thinking? My current code actually does do that, but my multiple extent change listeners are at cross purposes with one another. The extents do all change, but the trace functions I've put in show that it is just looping around and around.
... View more
12-23-2010
04:40 AM
|
0
|
0
|
264
|
POST
|
I've worked on this more and I am able to start a 2nd map with a new layer and it will inherit the map extent of the original map. This is sort of working now, but I'm stuck on the extent change listeners. It starts out to work OK, but since I have multiple maps, the changing extents are just looping around each other. I was wondering if maybe I should be finding a way to systematically be turning on/off the extent change listeners so I don't end up in an infinite loop. You'll see I have different functions for the extent change and that I'm attempting to turn the listeners off and on depending on which map has the focus. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" xmlns:components="components.*" layout="horizontal" pageTitle="" backgroundColor="#F8EEC5" initialize="initMap()"> <mx:Script> <![CDATA[ import com.esri.ags.SpatialReference; import com.esri.ags.Map; import mx.collections.ArrayCollection; import com.esri.ags.layers.Layer; import com.esri.ags.layers.ArcGISDynamicMapServiceLayer; import com.esri.ags.layers.ArcGISTiledMapServiceLayer; import com.esri.ags.geometry.Extent; import com.esri.ags.events.ExtentEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.utils.WebMercatorUtil; import com.esri.ags.Units; import mx.containers.Canvas; import mx.controls.Alert; import mx.utils.ObjectUtil; import flash.utils.ByteArray; import mx.managers.FocusManager; public var comboList:Array = ["Median Income","View Social Vunerability","View Unemployment"]; public var LayerList:Array = ["medIncomeLayer","socialVunLayer","unemployLayer"]; // public var medIncomeLayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer; public var socialVunLayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer; public var unemployLayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer; [Bindable] public var LayerArray:ArrayCollection = new ArrayCollection; public var canvasCounter:Number = 1; public var mapArray:ArrayCollection = new ArrayCollection; public var map2:Map = new Map (); public var map3:Map = new Map (); public function initMap() : void { socialVunLayer.id = "socialVunLayer"; socialVunLayer.alpha=0.7; socialVunLayer.visible=true; socialVunLayer.url= "http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Social_Vulnerability_Index/MapServer"; unemployLayer.id="unemployLayer"; unemployLayer.alpha=0.7; unemployLayer.visible=true; unemployLayer.url="http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Unemployment_Rate/MapServer"; } public function changeMap(): void { var chosenLayer:String = layerPickList1.text; if (canvasCounter < 3) { canvasCounter = canvasCounter + 1; var myMap:Map = new Map (); var eventName:String = "onExtentChange"+canvasCounter; myMap.id="map"+ canvasCounter; switch (eventName) { case "onExtentChange2": myMap = map2; myMap.id="map2"; myMap.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange2); break; case "onExtentChange3": myMap = map3; myMap.id="map3"; myMap.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange); break; } var beginExtent:Extent = mainMap.extent; var spatRef:SpatialReference = mainMap.extent.spatialReference; myMap.extent = beginExtent; myMap.extent.spatialReference = mainMap.extent.spatialReference; switch (chosenLayer) { case "View Social Vunerability": myMap.addLayer(socialVunLayer); break; case "View Unemployment": myMap.addLayer(unemployLayer); break; } mapBox.addChild(myMap); myMap.extent = mainMap.extent; myMap.extent.spatialReference = mainMap.extent.spatialReference; myMap.scale = mainMap.scale; }else { Alert.show ("Maximum number of maps reached") ; } mainMap.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange); } public function onExtentOff () : void { trace ("extentEvent turned off"); } public function onExtentChange(event:ExtentEvent):void { map2.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); map3.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); map2.extent = mainMap.extent; map3.extent = mainMap.extent; map2.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange2); map3.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange3); } public function onExtentChange2(event:ExtentEvent):void { mainMap.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); map3.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); mainMap.extent = map2.extent; map3.extent = map2.extent; mainMap.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange); map3.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange3); } public function onExtentChange3(event:ExtentEvent):void { mainMap.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); map2.removeEventListener(ExtentEvent.EXTENT_CHANGE,onExtentOff); mainMap.extent = map3.extent; map2.extent = map3.extent; mainMap.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange); map2.addEventListener(ExtentEvent.EXTENT_CHANGE, onExtentChange2); } ]]> </mx:Script> <mx:VBox height="100%" width="100%"> <mx:ComboBox id="layerPickList1" change="changeMap()" paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" dataProvider="{comboList}" x="67"/> <mx:HBox visible="false" includeInLayout="false"> <mx:Label text="Current map extent:" fontWeight="bold"/> <mx:Label text="xmin: {mainMap.extent.xmin.toFixed(3)}"/> <mx:Label text="ymin: {mainMap.extent.ymin.toFixed(3)}"/> <mx:Label text="xmax: {mainMap.extent.xmax.toFixed(3)}"/> <mx:Label text="ymax: {mainMap.extent.ymax.toFixed(3)}"/> <mx:Label text="Current map scale:" fontWeight="bold"/> <mx:Label text="1:{mainMap.scale.toFixed(0)}"/> </mx:HBox> <mx:HBox height="100%" width="100%" id="mapBox"> <esri:Map id="mainMap" units="{Units.METERS}" visible="true" > <esri:extent > <esri:Extent id="startExtent" xmin="-10944809" ymin="4276422" xmax="-9568555" ymax="5020001"> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer id="medIncomeLayer" alpha="0.7" visible="true" url="http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServer" /> </esri:Map> </mx:HBox> </mx:VBox> </mx:Application>
... View more
12-22-2010
11:10 AM
|
0
|
0
|
264
|
POST
|
I am starting out with a map and a combo box with 3 different layers in it. As you pick different layer names from the combo box, that layer is turned on and the other turns off. <esri:Map id="mainMap" width="100%" height="100%" units="{Units.METERS}" visible="true" initialize"initMap()"> <esri:extent > <esri:Extent id="startExtent" xmin="-10944809" ymin="4276422" xmax="-9568555" ymax="5020001"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer id="medIncomeLayer" alpha="0.7" visible="true" url="http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Median_Household_Income/MapServer" /> <esri:ArcGISTiledMapServiceLayer id="socialVunLayer" alpha="0.7" visible="false" url="http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Social_Vulnerability_Index/MapServer" /> <esri:ArcGISTiledMapServiceLayer id="unemployLayer" alpha="0.7" visible="false" url="http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Unemployment_Rate/MapServer" </esri:Map> This is the combo box: mx:ComboBox id="layerPickList1" change="changeMap(mainMap)" paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" dataProvider="{comboList}" x="67"/> This is the array that is populating it: public var comboList:Array = ["Median Income","Social Vunerability","Unemployment"]; public var LayerList:Array = ["medIncomeLayer","socialVunLayer","unemployLayer"]; [Bindable] public var LayerArray:ArrayCollection = new ArrayCollection; This is my function that changes the map: public function changeMap (myMap:Map): void { var mapName:String = myMap.id; var chosenLayer:String = layerPickList1.text; var listPosition:Number = comboList.indexOf(chosenLayer); var displayLayer:Object = LayerList[comboList.indexOf(chosenLayer)]; for each (var mapLayer:Layer in LayerArray) { trace (mapLayer.id); if (mapLayer.id == displayLayer) { mapLayer.visible=true; } else { mapLayer.visible=false; } } } I have a function that runs when the map initializes that just puts the 3 layers of the map in an arraycollection. public function initMap () : void { LayerArray.addItem(medIncomeLayer); LayerArray.addItem(socialVunLayer); LayerArray.addItem(unemployLayer); } My issue is that I want to be able to open up additional maps and use the same 3 layers. I can't just use the arraycollection I've made on the 2nd /3rd / 4th maps because all this does is move the layers from my original main map and put it on the newly created maps. I know I can add set more maps and use the same layers again with different names and set up more comboboxes too for each. However this sounds like such a sloppy hack-y way to go about it. Mostly I can't figure out a work around to the fact I can't seem to clone the arraycollection. I've looked all around and found some working examples on the web (http://nces.ed.gov/surveys/sdds/ed/index.asp is posted on the ESRI forum but without the code.
... View more
12-20-2010
12:32 PM
|
0
|
4
|
643
|
POST
|
Better yet, I'd really like to see the Code Gallery actually contain CODE! Whatever happened with that? In the previous resources set up, the code gallery contained example of source code so that users could see how a particular functionality was written. Instead it seems to have become another place where people can post their finished projects. To complicate matters, it seems that things that were posted originally at arcgis.com (with or without the code to go along) have made their way into the Code Gallery. I was all set to complain that people were using this Code Gallery incorrectly and then noticed that my own application (which I'd posted as a Web App) shows up there. I certainly didn't post it as a code example, because I didn't include the source code when I made my entry. I think the new pages are forums are very unclear about the best place to post code and the best way to access it. I took advantage of all the samples in the previous forum and I really miss being able to readily get to the code!
... View more
11-24-2010
09:23 AM
|
0
|
0
|
543
|
POST
|
I have finished learning Flex. But when I study Esri Flex API using Flex Builder, I still feel there are a lot I don't know. I have a task to finish using flex API, if I study 8 hours each day, usually how long does an average person take to use flex API to create some new flex application for web map? Thank you very much! Any experience or advise will help me a lot! I actually started by digging into the FLEX samples and only looked at Adobe FLEX help and examples as I needed to frame in around it. I didn't have much programming experience and I spent about 400 hrs over 6-7 months before I got my first app up and running. Depending on how plain or fancy you want to get it could be more or less time. I'd suggest working specifically through the basic samples that are posted on the ESRI site. Each of those examples really only do one or two things. This is good since you don't have too many lines of code to deal with. Since they are rather basic, I didn't find it too difficult to copy functions etc into a new file and get my code to do just one more thing. The applications I've dealt with use quite a few query tasks, data grids and the use of listeners on graphic layers. Query tasks have several examples, but I had to dig around to find examples of the interaction of the ESRI attributes with the datagrid.
... View more
11-24-2010
08:16 AM
|
0
|
0
|
111
|
POST
|
Yes, I have a listener on the graphic for MouseClick which was added through the results function for a query task. The onMouseClick function does a mainMap.infoWindow.show. I did as you suggested and added a variable, lastGraphic, to store the graphic and then added the listener for the InfoWindow during that onMouseClick function as well. private function onMouseClick(event:MouseEvent):void {
//adds a info tip window when you click on a map feature
var g:Graphic = Graphic(event.currentTarget);
lastGraphic = g;
mainMap.infoWindow.data = g.attributes;
mainMap.infoWindow.styleName = "myInfoWindow";
mainMap.infoWindow.show( MapPoint(g.geometry) );
mainMap.infoWindow.addEventListener("zoomHere",zoomHandler);
} Then when I got to the zoomHandler, I had the graphic stored and could then zoom to it. public function zoomHandler(event:Event): void {
var newMapPoint:MapPoint = MapPoint(lastGraphic.geometry);
if (mainMap.scale > 100000)
{
mainMap.scale = 100000;
} else {
var zoomScale:Number = mainMap.scale / 4;
mainMap.scale = zoomScale;
}
mainMap.centerAt( newMapPoint);
} Works well! Thanks Dasa!
... View more
11-01-2010
01:59 PM
|
0
|
0
|
358
|
POST
|
At least it is now getting to my zoomHandler event. However, the click graphic (which it doesn't look like I copied my code right last time) returns as null. I'm getting confused on whether I should dispatch an Event or MouseEvent. public function zoomHandler(event:MouseEvent): void {
var clickGraphic:Graphic = event.currentTarget as Graphic;
var newMapPoint:MapPoint = MapPoint(clickGraphic.geometry);
if (mainMap.scale > 100000)
{
mainMap.scale = 100000;
} else {
var zoomScale:Number = mainMap.scale / 4;
mainMap.scale = zoomScale;
}
mainMap.centerAt( newMapPoint);
}
... View more
11-01-2010
01:34 PM
|
0
|
0
|
358
|
POST
|
I'm using a queryTask to define tooltips, graphic, listeners etc. I have an infoWindow that comes up when the user clicks a point. I'd like to be able to add a button within the infoWindow that zooms to the point when the user clicks that button. I've added a listener to the graphic: myGraphic.addEventListener("zoomHere",zoomHandler); Then wrote the handler function: public function zoomHandler(event:MouseEvent): void {
var newMapPoint:MapPoint = MapPoint(lastGraphic.geometry);
if (mainMap.scale > 100000)
{
mainMap.scale = 100000;
} else {
var zoomScale:Number = mainMap.scale / 4;
mainMap.scale = zoomScale;
}
mainMap.centerAt( newMapPoint);
} I'm not sure exactly how or where to call the click event. There isn't any error when I compile, but the event handler I created never gets called. So maybe I don't have the listener added to the right thing? I was able to add a listener to the whole Infow window using mainMap.infoWindow.addEventListener(MouseEvent.CLICK,zoomHandler), but I really only want the event on the button, not the whole infoWindow. <mx:Component className="MyInfoWindowRenderer" >
<mx:VBox verticalGap="-5" height="100%">
<infoClasses:InfoWindowLabel styleName="balloonTitle" text="{data.FACILITY}" width="100%"/>
<mx:Label text="{data.ADDRESS}" />
<mx:Label text="{data.CITY}"/>
<mx:Label includeInLayout="{data.PHONE1 != ''? true:false}"
visible="{data.PHONE1 != ''? true:false}" text="Phone: {data.PHONE1}"/>
<mx:Label includeInLayout="{data.PHONE2 != ''? true:false}"
visible="{data.PHONE2 != ''? true:false}"
text="Phone: {data.PHONE2}"/>
<mx:Label includeInLayout="{data.PHONE3_FB != ''? true:false}"
visible="{data.PHONE3_FB != ''? true:false}"
text="Phone: {data.PHONE3_FB}"/>
<!-- <mx:Label includeInLayout="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}"
visible="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}"
text="Phone: {data.PHONE3_FB}"/>
-->
<mx:Label includeInLayout="{data.DAYS != ''? true:false}"
visible="{data.DAYS != ''? true:false}"
text="---------------------------------------" />
<mx:Label includeInLayout="{data.DAYS != ''? true:false}"
visible="{data.DAYS != ''? true:false}"
text="{data.DAYS}"/>
<mx:Label includeInLayout="{data.HOURS != ''? true:false}"
visible="{data.HOURS != ''? true:false}"
text="{data.HOURS}"/>
<mx:Label includeInLayout="{data.CERTIFICATION != ''? true:false}"
visible="{data.CERTIFICATION != ''? true:false}" text="---------------------------------------" />
<mx:TextArea width="100%" height="60" fontSize="11" includeInLayout="{data.CERTIFICATION != ''? true:false}"
visible="{data.CERTIFICATION != ''? true:false}"
text="{data.CERTIFICATION}"/>
<mx:Label includeInLayout="{data.LOC_CODE != 'CENT'? false:true}"
visible = "{data.LOC_CODE != 'CENT'? false:true}"
text="** Location Approximate **"/>
<mx:Button label="Zoom Closer" id="btn_Zoom" >
<mx:click>
<![CDATA[
dispatchEvent(new Event("zoomHere", true));
]]>
</mx:click>
</mx:Button>
</mx:VBox>
</mx:Component> The
... View more
10-29-2010
07:31 AM
|
0
|
6
|
990
|
POST
|
Not it either. I decided this wasn't just a ESRI/FLEX issue, but could be an issue with anything that's using data binding. I searchd Google and found this, which worked: <mx:Label includeInLayout="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}" visible="{(data.PHONE1 == '' && data.PHONE2 == '') ? true:false}" text="Phone: {data.PHONE3_FB}"/> I wouldn't have thought actually putting in the ampersands that way would work. What do I know - I'm not a programmer, I just play one when I come to work!
... View more
10-27-2010
09:00 AM
|
0
|
0
|
225
|
POST
|
Yes I do - thanks for catching that. Unfortunately I still have an error: The entity name must immediately follow the '&' in the entity reference. I'm not sure what "entity name" is, but since data.Phone2 does follow right after the &, that wouldn't seem to be it.
... View more
10-27-2010
08:37 AM
|
0
|
0
|
225
|
POST
|
I have successfully used a definition query on my map service for a couple of projects and haven't been having any problems. Basically it filters out the data before it ever gets to the service.
... View more
10-27-2010
08:32 AM
|
0
|
0
|
227
|
POST
|
I have a component for my infoWindow set up to only show when a particular field has data in it. This has worked quite well for me to 'close the gap' of blank lines when I don't have data in a particular field. I now have an instance where I only want to show "field3" if "field1" and "field2" are both blank. I tried combining the two, but I'm getting an error. I don't know if I can't do this, or if I've just got a syntax problem. <mx:Component className="MyInfoWindowRenderer"> <mx:VBox verticalGap="-5" height="100%"> <infoClasses:InfoWindowLabel styleName="balloonTitle" text="{data.FACILITY}" width="100%"/> <mx:Label text="{data.ADDRESS}" /> <mx:Label text="{data.CITY}, {data.STATE}, {data.ZIP}"/> <mx:Label includeInLayout="{data.PHONE1 != ''? true:false}" visible="{data.PHONE1 != ''? true:false}" text="Phone: {data.PHONE1}"/> <mx:Label includeInLayout="{data.PHONE2 != ''? true:false}" visible="{data.PHONE2 != ''? true:false}" text="Phone: {data.PHONE2}"/> <!-- this is the section that is failing ... --> <mx:Label includeInLayout="{(data.PHONE1 != ''? true:false) && (data.PHONE2 !== ''? true:false)}" visible="{(data.PHONE1 != ''? true:false) && (data.PHONE2 !== ''? true:false)}" text="Phone: {data.PHONE3_FB}"/> <mx:Label includeInLayout="{data.DAYS != ''? true:false}" visible="{data.DAYS != ''? true:false}" text="---------------------------------------" /> <mx:Label includeInLayout="{data.DAYS != ''? true:false}" visible="{data.DAYS != ''? true:false}" text="{data.DAYS}"/> <mx:Label includeInLayout="{data.HOURS != ''? true:false}" visible="{data.HOURS != ''? true:false}" text="{data.HOURS}"/> <mx:Label includeInLayout="{data.CERTIFICATION != ''? true:false}" visible="{data.CERTIFICATION != ''? true:false}" text="---------------------------------------" /> <mx:TextArea width="100%" height="60" includeInLayout="{data.CERTIFICATION != ''? true:false}" visible="{data.CERTIFICATION != ''? true:false}" text="{data.CERTIFICATION}"/> <mx:Label includeInLayout="{data.LOC_CODE != 'CENT'? false:true}" visible = "{data.LOC_CODE != 'CENT'? false:true}" text="** Location Approximate **"/> </mx:VBox> </mx:Component>
... View more
10-27-2010
08:21 AM
|
0
|
5
|
684
|
POST
|
Got it! So this worked: <mx:Component className="MyCountyWindowRenderer"> <mx:VBox verticalGap="-5"> <infoClasses:InfoWindowLabel styleName="myInfoTitle" text="{data.NAME2}" width="150%"/> <mx:Label text='Total Children under 72 Months: {data.POPULATION}' /> <mx:NumberFormatter id="labelFormatter" useThousandsSeparator="true" /> <mx:Label text="{labelFormatter.format(data.POPULATION)}" /> <mx:Label text= "Number Tested: {data.TESTOUTCOME}" /> <mx:Label text= "Age 0-35 Months Tested: {data.TEST_0_35}" /> <mx:Label text= "Age 36-71 Months Tested: {data.TEST_36_71}" /> <mx:Label text= "Number Elevated: {data.ELEVATED}" /> <mx:Label text= "Test Rates per 1000: {data.RATE}" /> </mx:VBox> </mx:Component>
... View more
09-09-2010
02:02 PM
|
0
|
0
|
156
|
Title | Kudos | Posted |
---|---|---|
1 | 03-18-2022 10:14 AM | |
1 | 02-18-2016 06:28 AM | |
1 | 03-18-2024 07:29 AM | |
4 | 08-02-2023 06:08 AM | |
1 | 10-26-2022 08:27 AM |
Online Status |
Offline
|
Date Last Visited |
4 weeks ago
|