POST
|
Hi, Fiona 1 - Where ESRI team works with FeatureSet? Right, when receiving the query results. So the pattern/example of FeatureSet in JSON = server query response in JSON format. It described in ArcGIS Server REST API help. 2 - Sample My JSON {
"displayFieldName" : "description",
"fieldAliases" : {
"objectid" : "Object ID",
"type" : "Type",
"description" : "Description"
},
"geometryType" : "esriGeometryPoint",
"spatialReference" : {
"wkid" : 4326
},
"fields" : [
{
"name" : "objectid",
"type" : "esriFieldTypeOID",
"alias" : "Object ID"
},
{
"name" : "type",
"type" : "esriFieldTypeInteger",
"alias" : "Type"
},
{
"name" : "description",
"type" : "esriFieldTypeString",
"alias" : "Description",
"length" : 1073741822
}
],
"features" : [
{
"attributes" : {
"objectid" : 2010,
"type" : 3,
"description" : "xzc"
},
"geometry" : {
"x" : -117.53253785200002,
"y" : 34.244472716000075
}
},
{
"attributes" : {
"objectid" : 2011,
"type" : 0,
"description" : "adf"
},
"geometry" : {
"x" : -100.62294522999991,
"y" : -15.344261442999937
}
}
]
} JSON from ESRI help {
"displayFieldName" : "AREANAME",
"fieldAliases" : {
"ST" : "ST",
"POP2000" : "Population - 2000",
"AREANAME" : "City Name"
},
"fields" : [
{
"name" : "ST",
"alias" : "ST",
"type" : "esriFieldTypeString",
"length" : 2
},
{
"name" : "POP2000",
"alias" : "Population - 2000",
"type" : "esriFieldTypeInteger"
},
{
"name" : "AREANAME",
"alias" : "City Name",
"type" : "esriFieldTypeString",
"length" : 255
}
],
"geometryType" : "esriGeometryPoint",
"spatialReference" : {"wkid" : 4326},
"features" : [
{
"attributes" : {
"ST" : "CA",
"POP2000" : 3694820,
"AREANAME" : "Los Angeles"
},
"geometry" : { "x" : -118.37, "y" : 34.086 }
},
{
"attributes" : {
"ST" : "CA",
"POP2000" : 461522,
"AREANAME" : "Long Beach"
},
"geometry" : { "x" : -118.15, "y" : 33.80 }
}
]
} JSON as query result http://goo.gl/Eys4N ------------------ App with input panel. Run, paste JSON in panel and push "Add features" button <?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:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags">
<s:layout>
<s:VerticalLayout gap="10"
paddingBottom="10"
paddingLeft="10"
paddingRight="10"
paddingTop="10" />
</s:layout>
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import com.esri.ags.Graphic;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.symbols.SimpleFillSymbol;
import com.esri.ags.symbols.SimpleLineSymbol;
import com.esri.ags.symbols.SimpleMarkerSymbol;
import com.esri.ags.utils.JSONUtil;
import mx.controls.Alert;
private var sms:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_TRIANGLE, 22, 0x00FF00);
private var sls:SimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0xFF0000);
private var sfs:SimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_DIAGONAL_CROSS, 0x0000FF);
protected function onAddButtonClick(event:MouseEvent):void
{
var jsonString:String = txtInput.text;
if (jsonString.length > 0)
{
try
{
var jsonObj:* = JSONUtil.decode(jsonString);
if (rbtnFeatureSetType.selected)
{
var featureSet:FeatureSet = FeatureSet.fromJSON(jsonObj);
if (featureSet && featureSet.features)
{
addGraphicsToMap(featureSet.features);
}
}
else
{
Alert.show("JSON string is valid", "Message");
// TODO: complete code
}
}
catch (error:Error)
{
trace(error.getStackTrace());
Alert.show("The input string cannot be parsed", "Error");
}
}
else
{
Alert.show("You must input valid json string in text area", "Error");
}
}
private function addGraphicsToMap(graphics:Array):void
{
if (graphicsLayer)
{
var isModified:Boolean = false;
for (var i:int; i < graphics.length; i++)
{
var graphic:Graphic = graphics;
if (graphic && graphic.geometry)
{
var geometry:Geometry = graphic.geometry;
switch (geometry.type)
{
case Geometry.MAPPOINT:
graphic.symbol = sms;
break;
case Geometry.POLYLINE:
graphic.symbol = sls;
break;
case Geometry.POLYGON:
graphic.symbol = sfs;
break;
}
trace("Added graphic id=" + graphicsLayer.add(graphic));
isModified = true;
}
}
if (isModified)
{
graphicsLayer.refresh();
}
}
}
]]>
</fx:Script>
<fx:Script>
<![CDATA[
protected function onClearButtonClick(event:MouseEvent):void
{
if (graphicsLayer)
{
graphicsLayer.clear();
}
}
]]>
</fx:Script>
<fx:Declarations>
<s:RadioButtonGroup id="rbtnGroup"/>
</fx:Declarations>
<s:Panel title="Map panel"
width="100%"
height="100%">
<s:layout>
<s:VerticalLayout gap="5"
verticalAlign="middle"
horizontalAlign="center" />
</s:layout>
<s:Button label="Clear graphics"
click="onClearButtonClick(event)" />
<esri:Map id="map">
<esri:ArcGISTiledMapServiceLayer id="baseLayer"
url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"
alpha="0.7" />
<esri:GraphicsLayer id="graphicsLayer" />
</esri:Map>
</s:Panel>
<s:Panel title="Input panel"
width="100%"
height="100%">
<s:layout>
<s:VerticalLayout gap="5"
verticalAlign="middle"
horizontalAlign="center"
paddingBottom="5"/>
</s:layout>
<s:TextArea id="txtInput"
width="100%"
height="100%" />
<s:HGroup width="100%"
horizontalAlign="center"
gap="20">
<s:RadioButton id="rbtnFeatureSetType"
label="is FeatureSet"
selected="true"
group="{rbtnGroup}"/>
<s:RadioButton id="rbtnCustomType"
label="is not FeatureSet"
group="{rbtnGroup}" />
<s:Button label="Add features"
click="onAddButtonClick(event)" />
</s:HGroup>
</s:Panel>
</s:Application> P.S. here similar discussion with sample for oldest API P.S.2 The JSON Validator
... View more
03-14-2013
12:01 AM
|
0
|
0
|
305
|
POST
|
1 - use forum search [ATTACH=CONFIG]22341[/ATTACH] 2 - take a time to learn API or interested Application 3 - api samples and viewer samples UPD similar thread
... View more
03-04-2013
02:55 AM
|
0
|
0
|
155
|
POST
|
Sample page has notice All the Flex API samples are also included in the Flex API Library download. So try to run sample with same name from downloaded api (not from web help), its code has some differences with it's web version. This sample works. In this sample (in API) map listener is added once and never removed. Good luck. P.S. map click event listener works fine when placed in right place and added in right moment
... View more
02-25-2013
10:07 PM
|
0
|
0
|
152
|
POST
|
Hi, IMHO you have a choise [INDENT]1[/INDENT] [INDENT]- create web service wich returns all/needed files from arcgis server output directory (for example: .NET Directory.GetFiles() );[/INDENT] [INDENT]- call this service from flex client (Your flex map application)[/INDENT] [INDENT]all business logic run on server[/INDENT] or [INDENT]2[/INDENT] [INDENT]- create geoprocessing task wich retuns all/needed files from arcgis server output directory, publish task on arcgis server;[/INDENT] [INDENT]- call this task using arcgis api for flex;[/INDENT] [INDENT]all business logic run on arcgis server[/INDENT] or [INDENT]3[/INDENT] [INDENT]- configure arcgis output directory as virtual directory (here is discussion);[/INDENT] [INDENT]- access it from flex client (Your flex map application);[/INDENT] [INDENT]- loop through folder contents to get needed file names;[/INDENT] [INDENT]all business logic on client side;[/INDENT]
... View more
02-25-2013
09:27 PM
|
0
|
0
|
113
|
POST
|
Hi steve. What is the base idea? Why do you need to keep graphics layers in separate container? Even if it would have been possible to hold the layers in "UIComponent" it would not give you anything. UIComponent The UIComponent class is the base class for all visual components, both interactive and noninteractive. The UIComponent class is not used as an MXML tag, but is used as a base class for other classes. But if there is a need in the container, why not take "ArrayCollection"? private var myGraphicsLayersCollection:ArrayCollection = new ArrayCollection();
private function addGraphicsLayerToCollection():void {
var grLayer:GraphicsLayer = new GraphicsLayer();
grLayer.id = "grLayer1";
grLayer.name = "First Gr Layer";
myGraphicsLayersCollection.addItem(grLayer);
}
private function getGraphicsLayerFromCollectionById(layerId:String):GraphicsLayer {
for each (var layer:GraphicsLayer in myGraphicsLayersCollection) {
if (layerId == layer.id) {
return layer;
}
}
return null;
}
private function removeGraphicsLayerFromCollectionById(layerId:String):Boolean {
var isRemoved:Boolean = false;
for each (var layer:GraphicsLayer in myGraphicsLayersCollection) {
if (layerId == layer.id) {
var index:int = layerList.getItemIndex(layer);
layerList.removeItemAt(index);
isRemoved = true;
break;
}
}
return isRemoved;
}
private function collectionToMap():void {
for each (var layer:GraphicsLayer in myGraphicsLayersCollection) {
// each layer extends UIComponent, so its ID is unique
var existingLayer:Layer = mapMap.getLayer(layer.id);
if (!existingLayer)
mapMap.addLayer(layer);
}
} Sample - [ATTACH=CONFIG]22038[/ATTACH]
... View more
02-21-2013
02:42 AM
|
0
|
0
|
123
|
POST
|
Debugging tips from adobe site with sample code: Debugging basics Breakpoints Variables view, watchpoints, and Run to Line Debugging tips from ArcGIS team: ArcGIS API for Flex Debugging tips You also need to install debug version of flash player Good luck UPD AdobeTV: flex debugging Adobe video training "Flex in a week": Verifying data retrieval with Debugger and Network Monitor
... View more
02-17-2013
09:32 AM
|
0
|
0
|
558
|
POST
|
by the same way like you just added it using remove() function myGaphicsLayer.remove(myTextGraphic) remove() method public function remove(graphic:Graphic):void Removes the specific graphic. Parameters graphic:Graphic �?? The graphic to remove. See also com.esri.ags.events.GraphicEvent.GRAPHIC_REMOVE
... View more
02-12-2013
09:31 PM
|
0
|
0
|
497
|
POST
|
I thought I had tried it, but browsercaching is also terrible here when debugging flex/flash applications... Find C:\Users\User Name\mm.cfg (if file doesn't exist create it) How to change flash player debugger configuration file
... View more
02-12-2013
04:57 AM
|
0
|
0
|
472
|
POST
|
fix it private function init():void
{
//...
initWheelEvents();
} if not success, please show your code (ViewerContainer.mxml as it is) UPD - working application
... View more
02-11-2013
08:12 AM
|
0
|
0
|
472
|
POST
|
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:s="library://ns.adobe.com/flex/spark"
initialize="initApp()"
pageTitle="Example - using Renderers">
<!--
Based on this sample http://resources.arcgis.com/en/help/flex-api/samples/index.html#/Using_Renderers/01nq00000052000000/
-->
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.GraphicEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.symbols.Symbol;
private function initApp():void
{
var i:int, mapX:Number, mapY:Number, graphic:Graphic;
// add 100 random graphics to the GraphicsLayer
for (i; i < 100; i++)
{
mapX = Math.random() * 40044000 - 20022000;
mapY = Math.random() * 40044000 - 20022000;
var attributes:Object = { "ranking": Math.random()};
graphic = new Graphic(
new MapPoint(mapX, mapY),
null,
attributes
);
graphic.toolTip = "Ranking: " + Number(graphic.attributes.ranking).toFixed(3);
graphicsLayer.add(graphic);
}
// add 10 random graphics to the GraphicsLayer
for (i = 0; i < 10; i++)
{
mapX = Math.random() * 40044000 - 20022000;
mapY = Math.random() * 40044000 - 20022000;
graphic = new Graphic(
new MapPoint(mapX, mapY),
blueSym
);
graphic.toolTip = "Item without ranking";
graphicsLayer.add(graphic);
}
}
protected function onGraphicAdd(event:GraphicEvent):void
{
var gr:Graphic = event.graphic;
gr.addEventListener(MouseEvent.CLICK, onGraphicClick);
}
private var lastGraphic:Graphic = null;
private var lastSymbol:Symbol = null;
protected function onGraphicClick(event:MouseEvent):void
{
var gr:Graphic = Graphic(event.target);
// remove listener if needed
//gr.removeEventListener(MouseEvent.CLICK, onGraphicClick);
restoreLastGraphicSymbol();
highlightSelectedGraphic(gr);
}
private function restoreLastGraphicSymbol():void
{
if (lastGraphic && lastSymbol)
{
// find last clicked graphic
for each(var gr:Graphic in graphicsLayer.graphicProvider)
{
if (gr.id == lastGraphic.id)
{
// restore symbol
gr.symbol = lastSymbol;
// restore listener if removed
//gr.addEventListener(MouseEvent.CLICK, onGraphicClick);
break;
}
}
}
}
private function highlightSelectedGraphic(graphic:Graphic):void
{
// backup graphic
lastGraphic = graphic;
// backup its symbol
if (graphic.symbol)
{
lastSymbol = graphic.symbol;
}
else
{
lastSymbol = graphicsLayer.renderer.getSymbol(graphic);
}
// set highlight symbol
graphic.symbol = highlightSym;
}
]]>
</fx:Script>
<fx:Declarations>
<esri:SimpleMarkerSymbol id="blueSym"
style="triangle"
alpha="0.7"
color="0x0000FF"
size="14"/>
<esri:SimpleMarkerSymbol id="smallSym"
alpha="0.7"
color="0xFF0000"
size="6"/>
<esri:SimpleMarkerSymbol id="mediumSym"
alpha="0.7"
color="0xFF0000"
size="10"/>
<esri:SimpleMarkerSymbol id="largeSym"
alpha="0.7"
color="0xFF0000"
size="16"/>
<esri:SimpleMarkerSymbol id="highlightSym"
style="diamond"
alpha="0.7"
color="0xFFFF00"
size="16"/>
</fx:Declarations>
<esri:Map>
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<esri:GraphicsLayer id="graphicsLayer" graphicAdd="onGraphicAdd(event)">
<esri:renderer>
<esri:ClassBreaksRenderer field="ranking">
<esri:ClassBreakInfo maxValue="0.33" symbol="{smallSym}"/>
<esri:ClassBreakInfo maxValue="0.67"
minValue="0.33"
symbol="{mediumSym}"/>
<esri:ClassBreakInfo minValue="0.67" symbol="{largeSym}"/>
</esri:ClassBreaksRenderer>
</esri:renderer>
</esri:GraphicsLayer>
</esri:Map>
</s:Application>
... View more
01-31-2013
10:51 PM
|
0
|
0
|
340
|
POST
|
This sample demonstrates how to listen mose event on feature layer graphics 1 - listen feature layer graphic added event handler 2 - for each graphic add mouse event listener similar discussion
... View more
01-24-2013
07:39 AM
|
0
|
0
|
154
|
POST
|
Parse xml (the ArcGIS Flex Viewer is a big sample of how to do it) Create MapPoints from readed data, and existing layer SpatialReference Create array of Graphics with created geometries and required(not nullable) attributes applyEdits()
... View more
01-22-2013
08:13 PM
|
0
|
0
|
282
|
POST
|
WebTiledLayer sample Description: This sample demonstrates how to add various third-party (tiled|cached) map services to your ArcGIS API for Flex application using the WebTiledLayer class ... Sample of extending TiledMapServiceLayer
... View more
01-22-2013
04:17 AM
|
0
|
0
|
898
|
POST
|
Tiled map service has all needed information - via this property tileInfo you can access this information in flex Tile Info: [INDENT]Height: 512 Width: 512 DPI: 96 [INDENT]Levels of Detail: (# Levels: 16) Level ID: 0 [Start Tile, End Tile] Resolution: 0,3515625 Scale: 147748799,285417 Level ID: 1 [Start Tile, End Tile] Resolution: 0,17578125 Scale: 73874399,6427087[/INDENT][/INDENT] ... Additional info: find paragraph "Map Scale and Resolution:" Mathematical relationships...
... View more
01-22-2013
03:09 AM
|
0
|
0
|
898
|
POST
|
Nadeem, Geoprocessing tasks in ArcGIS API for Flex concepts Geprocessor tasks in ArcGIS API for Flex samples Publishing a geoprocessing service in ArcGIS Desktop help Geoprocessing service in ArcGIS Server REST API help
... View more
01-16-2013
01:53 AM
|
0
|
0
|
176
|
Title | Kudos | Posted |
---|---|---|
1 | 12-03-2017 11:25 PM | |
1 | 10-06-2016 11:49 PM | |
2 | 06-07-2012 01:38 AM | |
1 | 06-03-2012 09:42 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|