|
POST
|
Thanks Drew for your response. I would like to create a webpage that is somewhat similar to this: http://visudemos.ilog.com/blogsamples/factbook2/FactBookSE.html Would you be able to tell me what is the likely way they created this world map? I come from the Arc world of shapefiles and geodatabases, and I know that I can't overlap a shapefile into Flex, so I'm basically asking, if not a shapefile, how do they get a map to show up? Dan, What software do you have at your disposal? Do you have ArcGIS Server? As for how they created the world map.. Well its not using ESRI Flex api. Its something custom or another 3rd party like Avenza Web Map. You could do this with the ESRI flex API but I would not recommend it as your very first task. Drew
... View more
11-17-2010
05:02 PM
|
0
|
0
|
565
|
|
POST
|
Dan, Usually you would have your own map service that you would overlay on top of the basemap and not graphics. Graphics can be used but you need to know the exact geometry and this is not the most efficient way to display data right away. Generally graphics are used to emphasize a location or feature. Do you have access to ArcGIS Server and do you have a service published that contains the data you need to show? EDIT: Unless by graphic you are referring to a file such as a jpg, png, gif to overlay.... This is generally what the "map service" generates. I may have been reading you post from a programming perspective where "graphics" are added to the map to highlight a feature (like in ArcMap) Drew
... View more
11-17-2010
01:03 PM
|
0
|
0
|
565
|
|
POST
|
You could write your own function to join the data I guess. Below is a sample that appends to a feature set based on some sample data. It�??s a 1:1 join and the function is generic enough you could reuse it yourself (see joinData function) This has not been tested in a live app, but the returned featureSet looks complete.
<?xml version="1.0" encoding="utf-8"?>
<s:Application creationComplete="creationCompleteHandler(event)" xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags" width="755" height="600">
<fx:Declarations>
<!--
SAMPLE DATA
This is the data that will be joined to the GIS feature data.
-->
<s:ArrayCollection id="sampleData">
<fx:Object key="Connecticut" annualIncome="50000" averageFamlySize="5"/>
<fx:Object key="California" annualIncome="75000" averageFamlySize="4"/>
<fx:Object key="Colorado" annualIncome="60000" averageFamlySize="6"/>
<fx:Object key="North Carolina" annualIncome="55000" averageFamlySize="3"/>
<fx:Object key="South Carolina" annualIncome="65000" averageFamlySize="5"/>
</s:ArrayCollection>
<esri:QueryTask
id="queryTask"
useAMF="false"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/>
<esri:Query
id="query"
returnGeometry="true"
text="{stateName.text}"
outFields='["STATE_NAME","SUB_REGION"]'/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import com.esri.ags.Graphic;
import com.esri.ags.events.QueryEvent;
import mx.controls.Alert;
import mx.events.DataGridEvent;
import mx.events.FlexEvent;
import mx.events.ListEvent;
protected function creationCompleteHandler(event:FlexEvent):void
{
queryTask.addEventListener(QueryEvent.EXECUTE_COMPLETE, onQueryComplete)
}
private function executeQuery():void
{
queryTask.execute(query);
}
private function onQueryComplete(event:QueryEvent):void
{
var joinedResults:FeatureSet = joinData(event.featureSet, "STATE_NAME", sampleData, "key");
resultsGrid.dataProvider = joinedResults.attributes;
}
//---------------------------------------------------
// 1:1 JOINING FUNCTION
//---------------------------------------------------
private function joinData(featureSet:FeatureSet, featureSetKeyColumn:String, relatedData:ArrayCollection, relatedDataKeyColumn:String):FeatureSet
{
//Loop through each feature.
for each (var feature:Graphic in featureSet.features)
{
//Loop through related to find a match
for each (var data:Object in relatedData)
{
//add new empty peopertys to the feature
for (var property:Object in data)
feature.attributes[property.toString()] = "";
//make both values UPPERCASE to compare
var featureKeyValue:String = feature.attributes[featureSetKeyColumn].toString().toUpperCase();
var relatedKeyValue:String = data[relatedDataKeyColumn].toString().toUpperCase();
//compare
if (featureKeyValue == relatedKeyValue)
{
//assign new value(s)
for (var prop:Object in data)
feature.attributes[prop.toString()] = data[prop.toString()].toString();
break; // get out of loop
}
}
}
return featureSet;
}
]]>
</fx:Script>
<mx:Panel title="Query Sample" height="300" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" left="10" right="10" top="10">
<mx:HBox>
<mx:Label text="US state name: " />
<mx:TextInput id="stateName" text="C" enabled="false" />
<mx:Button label="Get Details" click="executeQuery();" />
</mx:HBox>
<mx:DataGrid id="resultsGrid" width="100%" height="100%">
</mx:DataGrid>
</mx:Panel>
</s:Application>
Drew
... View more
11-11-2010
08:28 AM
|
0
|
0
|
530
|
|
POST
|
The easiest way to join data is to do it right in ArcMap, then refresh your map service and clear the rest cache to see the new data added. I would suggest YouTube and Google for resources on how to join tables using ArcMap. I have not completely reviewed this video, but the subject sounds like what you need. http://www.youtube.com/watch?v=i3WLTN25d8Q Drew
... View more
11-10-2010
06:16 AM
|
0
|
0
|
530
|
|
POST
|
I don't see such an event in the docs either. It would be nice too. Below is some code I wrote that should solve the problem. It seems like a lot but it works.
<?xml version="1.0" encoding="utf-8"?>
<s:Application name="Test"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags" >
<fx:Script>
<![CDATA[
//IMPORTS
import com.esri.ags.events.LayerEvent;
import com.esri.ags.events.MapEvent;
import com.esri.ags.layers.Layer;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
//-----------------------------------------
//PRIVATE VARIABLES
//-----------------------------------------
private var _isLayersLoaded:Boolean = false;
private var _layerLoadCount:int = 0;
// isLayersLoaded getter
// Checks if the private varibale _layerLoadCount == the total map layers in the map
public function get isLayersLoaded():Boolean
{
var loaded:Boolean;
var mapLayers:ArrayCollection = this.map.layers as ArrayCollection;
if (mapLayers.length == this._layerLoadCount)
loaded = true;
else
loaded= false;
return loaded;
}
//-----------------------------------------
// on Map Load loop through all the layers and check if loaded.
// if not loaded, listen for the load event to be called.
//-----------------------------------------
private function _onMapLoad(event:MapEvent):void
{
for each (var lyr:Layer in this.map.layers)
{
if (lyr.loaded)
_layerLoadCount++;
else
lyr.addEventListener(LayerEvent.LOAD, _onLayerLoad);
}
}
//-----------------------------------------
// if layer load event is called, add 1 to the _layerLoadCount variable.
//-----------------------------------------
private function _onLayerLoad(event:LayerEvent):void
{
_layerLoadCount++;
}
//-----------------------------------------
// Test the variable isLayersLoaded
//-----------------------------------------
private function onPrintClick():void
{
if (this.isLayersLoaded == false)
Alert.show("please wait, all layers are not yet loaded");
else
Alert.show("Layers Loaded!");
}
]]>
</fx:Script>
<esri:Map id="map" load="_onMapLoad(event)" top="76" bottom="10" left="9" right="10">
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/"/>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/"/>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/"/>
</esri:Map>
<s:Button x="10" y="47" label="Button" id="btnPrint" click="onPrintClick();"/>
</s:Application>
if you need further assistance feel free to ask.. Drew
... View more
11-05-2010
08:46 PM
|
0
|
0
|
889
|
|
POST
|
dkroy, Glad it worked so well. If you wanted to take it one step further you could create a base component that contains the map as a default property and have some error checking built in place to ensure its added at runtime. Then you would simply extend that base class for each new component you build. This would save you some time creating new components and ensure each components checked for the map property to be set and is named the same across your entire library. An example of a base component might be:
package
{
import com.esri.ags.Map;
import mx.controls.Alert;
import mx.events.FlexEvent;
import spark.components.Group;
public class BaseMapComponent extends Group
{
private var _map:Map;
public function get map():Map
{
return _map;
}
public function set map(value:Map):void
{
_map = value;
}
public function BaseMapComponent()
{
super();
this.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
}
private function onCreationComplete(event:FlexEvent) :void
{
validateMapPropertyIsSet();
}
private function validateMapPropertyIsSet():void
{
if (map == null)
{
Alert.show("Map property for (" + this.className + ") is not set. This tool may not work coorectly");
}
}
}
}
If you wanted to get even more fancy you could check if the map property is set and if not try and find the map component by looping through the applications children recursively. This functionality would not be good if you were planning on having more than one map on the stage though... and it could be problematic, but may be worth a test. Attached is a new sample that contains the base map component i described above. I would suggest going this way and extend it as needed.. It may be helpful too because if you are into skinning it might save time on that end too. Good luck, Drew
... View more
11-05-2010
05:06 PM
|
0
|
0
|
560
|
|
POST
|
You're most likely running into the get size limit. You're where clause is being written as a param in the call, so it's probably blowing up the url, passing in a partial where. Can't remember what the size is off the top of my head, but it's around a couple thousand. If you can force the call to switch to post you'll clear that limit. Of course, I don't know of a way to specify in the JSAPI query class how to switch to post, or if it does it automatically, but I would recommend sticking with the RESTful services, they're much easier to work with in general. It was the URL and i used the proxy page swingley linked above. It worked perfect. Thanks guys, Drew
... View more
11-03-2010
04:32 AM
|
0
|
0
|
769
|
|
POST
|
Dan, Assuming you don't have others consuming this service and require it to be named XYZ, you might want to delete the current one and recreate it with a new name. That might clear it up (for now 🙂 ) Drew
... View more
11-02-2010
12:28 PM
|
0
|
0
|
764
|
|
POST
|
Andrew, Not really sure why you would want to do this but I'll try to point you in the right area to look at. You are likely to break a lot of stuff trying to do this but I would look at the index.mxml which is the base spark application it has a child element that is the ViewerContainer. The ViewerContainer is just a mx canvas so I would put your hdivided box in the index.mxml and add the ViewerContainer to one of it's panels. Thanks Robert, I was digging around there for a while, but I will take a closer look now. The reason why I want to do this is because I am trying to get some widgets off the map and move things such as my TOC, Search controls, bookmarks and printing into a stationary part of the application. its just a way I prefer to lay out my GUI's. I am pretty sure I have a lot of work on my hands customizing the view completely, but it might pay off in the long run. Thanks again, Drew
... View more
11-02-2010
11:35 AM
|
0
|
0
|
619
|
|
POST
|
Hello, I am familiar with the ESRI Flex API, but not the 'Viewer' and am currently tasked with an application that requires the use of the ESRI Viewer. I am looking for a little info on how I can move the 'map' into a HDividedBox so I can have 2 panels in my application. One panel for large custom components (i.e TOC) and another for the map (similar to the ArcMap layout). I did see that I can move the map to a specific top & left, but I would preferably like to have it in a HDividedBox. Does anyone know how to I move the map into a HDividedBox ? - Using the ESRI 2.1 Viewer Source Code and the 2.1 API Drew
... View more
11-02-2010
10:31 AM
|
0
|
6
|
806
|
|
POST
|
dkroy, As you may know you can create a custom lib in Flex/Flash Builder by going to File->New Flex Lib Project. The build action of this type of file is a SWC and this is how other projects can reuse your components. No matter what each component will have to have a "Map" property so you know about the map and can work with its properties and events. An example of this might be:
<Coordinates:Viewer MapControl="{myMap}" left="10" right="10" top="10">
</Coordinates:Viewer>
A quick sample of the code for this component would be:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox creationComplete="creationCompleteHandler(event)"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400"
height="58"
paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10" backgroundColor="#606060">
<fx:Script>
<![CDATA[
import com.esri.ags.Map;
import com.esri.ags.geometry.MapPoint;
import mx.events.FlexEvent;
import mx.events.MoveEvent;
public var MapControl:Map;
[Bindable]
public var X:Number = 0;
[Bindable]
public var Y:Number = 0;
protected function creationCompleteHandler(event:FlexEvent):void
{
this.MapControl.addEventListener(MouseEvent.MOUSE_MOVE, onMapMouseMove);
}
private function onMapMouseMove(event:MouseEvent):void{
var screenPoint:Point = new Point(event.localX, event.localY);
var mapPoint:MapPoint = this.MapControl.toMap(screenPoint);
this.X = mapPoint.x;
this.Y = mapPoint.y;
}
]]>
</fx:Script>
<s:Label text="{this.X}" id="lblX"/>
<s:Label text="{this.Y}" id="lblY"/>
</mx:VBox>
Once you have your custom component somewhat built you can add a SWC Project to a new Flex Project to test. You can add your newly created library to a new Flex Project by going to: - Right click on your test project - Select properties - Navigate to "Flex Build Path" - Select the "Library Path" tab - Choose "Add Project" and chose your new custom library Attached is a custom component library with the sample i showed above - download, unzip and then import into your workspace. Hope this helps in some way.. Drew
... View more
11-01-2010
06:25 PM
|
0
|
0
|
560
|
|
POST
|
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>
... View more
10-28-2010
08:57 AM
|
0
|
0
|
447
|
|
POST
|
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;
}
... View more
10-28-2010
07:23 AM
|
0
|
0
|
447
|
|
POST
|
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
... View more
10-28-2010
06:31 AM
|
0
|
0
|
447
|
|
POST
|
After a little further reading your probably right and the JS API is restricting the call.. I will look at the proxy page you mentioned or just move to the SOAP API for my specific task. Thanks for your assistance Derek . Drew
... View more
10-27-2010
11:16 AM
|
0
|
0
|
769
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-04-2013 09:40 AM | |
| 1 | 12-11-2012 10:19 AM | |
| 1 | 05-25-2015 10:46 AM | |
| 1 | 05-10-2016 06:31 AM | |
| 1 | 01-17-2017 11:01 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-31-2021
09:54 AM
|