POST
|
Using a FeatureLayer the way I think you're intending, you would use the definitionExpression of the FL. Check this example. http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=FeatureLayer_Search Another method, that will work the way you have in your post is to use featureLayer.queryFeatures(), which basically sends its params to a queryTask.execute() inside the Featurelayer.
... View more
09-14-2010
10:33 AM
|
0
|
0
|
104
|
POST
|
I was curious if there was a clean way to remove particular selections from a Featurelayer. I tried a couple of different methods to limit the selection to first selected feature. I thought I could cheat and splice the selectedFeatures var x:uint = featurelayer.selectedFeatures.length;
featurelayerselectedFeatures.splice(1,x); But that didn't work. Then I tried to grab the first graphic and make a new FeatureCollection var g:Graphic = featurelayer.selectedFeatures[0];
featureLayer.featureCollection = new FeatureCollection(new FeatureSet( )); That didn't work either. The next step I suppose would be to use the first graphic geometry to do second selection query on the FeatureLayer, but that seems a bit heavy handed. The reason I am using FeatureLayer is that this is for a custom component and it is much simpler to pass a FeatureLayer with built in query/selection capabilities than to pass a QueryTask URL and an existing GraphicsLayer on the Map, plus it fits into my workflow as I have some listeners in the main app for when a selection ends on the FeatureLayer being passed. If there's no way to tweak the SelectedFeatures after the fact, I'll just go the QueryTask/GraphicsLayer route, but I figure it couldn't hurt to ask.
... View more
09-09-2010
07:51 AM
|
0
|
2
|
1885
|
POST
|
I think you'll need to listen for the UPDATE_COMPLETE event from the map after turning off the zoom slider.
map.addEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
map.zoomSliderVisible = false;
function onUpdateComplete_handler(e:FlexEvent):void {
map.removeEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateComplete_handler);
createPDF();
}
... View more
09-07-2010
12:15 PM
|
0
|
0
|
253
|
POST
|
I was using the Yahoo astra one, but I started using this one when I moved to Flex 4 http://flashcommander.org/blog/flex-4-autocomplete It works great for me.
... View more
09-04-2010
09:24 AM
|
0
|
0
|
157
|
POST
|
Hi Robert, I just wanted to give you a big thanks. I wanted to make sure it was ok with you that I've added your functions to build the swatches into a function in my flex library in my signature. SwatchFactory I couldn't find an email for you, or I would have just sent one. I put a sample up of how I'm using it in a non-widget capacity. Thanks again.
... View more
09-03-2010
09:09 AM
|
0
|
0
|
390
|
POST
|
Recently I noticed in the 2.0 API, there is no more LayerEvent.TILES_UPDATED, just a LayerEvent.UPDATE_END, which is great. Simplifies things quite a bit. When needing to manage Layers, i.e. - when they load and are complete, it would be great if the Flex API could dispatch a LayerEvent.UPDATE_END when layer.visible = false is peformed. I realize that visible is inherited from the UIComponent, but as of right now if you want to know that layer.visible has been set to false, you need to listen for FlexEvent.HIDE, but when layer.visible is set to true, you'll still get a LayerEvent.UPDATE_END event. That would mean that to manage visible layers in real time, I'd need to listen to 2 events from the same layer to do the same thing. Here is a code snippet that I currently use to deal with this situation.
map.addEventListener(MapEvent.LAYER_ADD, map_layerAddHandler)
protected var lyrCount:uint;
protected var lyrUpdateCount:uint;
protected function map_layerAddHandler(event:MapEvent):void {
var lyr:Layer = event.layer;
lyr.addEventListener(LayerEvent.UPDATE_END, onLayerUpdateEnd_handler);
lyr.addEventListener(FlexEvent.HIDE, function(e:Event):void{trace(e)});
lyr.addEventListener(FlexEvent.HIDE, onHide);
if (lyr.visible)
lyrCount++;
}
// I need to listen for the Hide event and manually dispatch a LayerEvent
// in order to have a proper count of current visible layers
protected function onHide(event:FlexEvent):void {
if (event.currentTarget is Layer) {
event.currentTarget.dispatchEvent(new LayerEvent(LayerEvent.UPDATE_END, event.currentTarget as Layer, null, true, false));
}
}
protected function onLayerUpdateEnd_handler(event:LayerEvent):void {
if (event.updateSuccess) {
lyrUpdateCount++;
var lyr:Layer
var tmpCount:uint = lyrCount;
lyrCount = 0;
for each (lyr in this.layers) {
if (lyr.visible)
lyrCount++;
}
trace("lyrCount",lyrCount);
trace("lyrUpdateCount",lyrUpdateCount);
trace("tmpCount",tmpCount);
if (lyrUpdateCount == lyrCount || lyrCount != tmpCount) {
lyrUpdateCount = 0;
}
}
}
It's really more of a convenience request, but it'd be nice to have. I figure since you're working on API 2.1, it couldn't hurt to ask. Thanks.
... View more
09-02-2010
08:34 AM
|
0
|
0
|
1893
|
POST
|
Ok, sorry. I got confused reading your earlier posts. Looking at what you have, you actually want to use a WebService, not an HTTPService. You'd use a WebService to send requests to a function and get results. An HTTPService would be used to load something like an XML or Text file. Here is an example of using a WebService with your service. Don't worry about converting to XML unless that's your thing.
<?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"
minWidth="955"
minHeight="600"
applicationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.mxml.WebService;
protected var service:WebService;
protected function init():void {
service = new WebService();
service.showBusyCursor = true;
service.wsdl = "http://data.cmap.illinois.gov/ws/tip/tipservice.asmx?wsdl";
service.addEventListener(ResultEvent.RESULT, onResultsLoaded_handler);
service.addEventListener(FaultEvent.FAULT, onFault_handler);
service.loadWSDL();
}
protected function onFault_handler(event:FaultEvent):void {
Alert.show("Error in calling service: " + event.message, "Error");
}
protected function onResultsLoaded_handler(event:ResultEvent):void {
try {
dgResults.dataProvider = event.result as ArrayCollection;
}
catch (e:Error) {
Alert.show("An error occurred loading results: " + e.message, "Results error");
}
}
protected function btnRequest_clickHandler(event:MouseEvent):void {
service.getproject(input.text);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout gap="5"
horizontalAlign="center"
paddingTop="25" />
</s:layout>
<s:TextInput id="input"
width="200" />
<s:Button id="btnRequest"
label="Send Request"
width="200"
click="btnRequest_clickHandler(event)" />
<mx:DataGrid id="dgResults"
width="800"
height="300" />
</s:Application>
Now as far as how this relates to the example you linked in your first post, the above will get you the ArrayCollection of results you were looking for in your first post. Now you can use those results to create a "where" query on your map service.
... View more
09-01-2010
01:28 PM
|
0
|
0
|
445
|
POST
|
Thanks for doing the leg work on this one Robert. I'm incorporating/tweaking your methods to create swatches into a current layer visibility component I have. Writing up/debugging those renderer symbols must have taken you forever.
... View more
09-01-2010
09:29 AM
|
0
|
0
|
626
|
POST
|
Try this You can go XML -> Array or ArrayCollection Don't forget to set your result format. service.resultFormat = "e4x"; var xml:XML = event.result as XML;
var items:Array = [];
for each (var queryXML:XML in xml.tipProject) {
var obj:Object = {
project:queryXML.@project,
agency:queryXML.@agency // and so on adding the fields you want
}
items.push(obj);
} You can also turn it into an XMLListCollection var xmlListCollection:XMLListCollection = new XMLListCollection(); xmlListCollection.source = new XMLList( event.result ); You can then treat the XMLListCollection like an ArrayCollection When dealing with an HTTPService, your results are easy to parse in XML, I never used ArrayCollection with an HTTPService result, but I think the event.result object is xml by default.
... View more
08-30-2010
12:57 PM
|
0
|
0
|
499
|
POST
|
An example of the .NET web service accessing an SDE could look something like this
[WebMethod(Description = "Returns Flow Control History Details")]
public DataTable FlowControlHistory(String objectID)
{
DataTable FlowTable = new DataTable();
System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("<your connection string here>");
connection.Open();
// build a sql expression to access your database data
// using a passed OBJECTID from a feature in flex
string strSQL = "SELECT DISTINCT t1.FLOWID " +
"FROM sde.SSCOMPLEXFLOWCONTROLHISTORY as t1 " +
"WHERE t1.OBJECTID = '" + objectID + "' " +
"UNION " +
"SELECT DISTINCT t2.FLOWID " +
"FROM sde.SSFLOWCONTROLHISTORY as t2 " +
"WHERE t2.OBJECTID = '" + objectID + "' " +
"ORDER BY FLOWID;
System.Data.OleDb.OleDbDataAdapter Adapter = new System.Data.OleDb.OleDbDataAdapter(strSQL, connection);
Adapter.Fill(FlowTable);
try
{
FlowTable.TableName = "Table";
}
finally
{
connection.Close();
}
return FlowTable;
}
Then in Flex, you'd do something like this.
protected var service:WebService;
protected var retry:uint = 0;
// send your Web Service WSDL to define a web service
public function setWsdl(value:String):void {
service = new WebService();
service.showBusyCursor = true;
service.wsdl = value;
service.addEventListener(FaultEvent.FAULT, WsdlFault, false, 0, true);
service.loadWSDL();
}
protected function onWsdlFault(fault:FaultEvent, token:Object = null):void {
// I always try to load a web service twice if I get a load error.
// Just in case, my network can laugh at me sometimes
retry++;
if (retry < 2)
service.loadWSDL();
else {
service.removeEventListener(FaultEvent.FAULT, WsdlFault);
Alert.show("A Web Service has failed to load. Please close the application and try again.", "Error");
}
}
// function that will call my web service
public function findRelatedFlowData(objectID:String):void {
var responder:AsyncResponder = new AsyncResponder(onFlowDataResults, onFault);
var request:AsyncToken = service.FlowControlHistory(objectID);
request.addResponder(responder);
}
proteced function onFlowDataResults(result:ResultEvent, token:Object = null):void {
var ac:ArrayCollection = result.result.Tables.Table.Rows;
// do something with results here
}
protected function onFault(fault:FaultEvent, token:Object = null):void {
// I always try to load a web service twice.
Alert.show("A Web Service error has occurred.", "Error");
}
This has always worked for me, plus by using C# or VB.NET you get a bit more control over your query. The relates in the ESRI API are still great and I use them for large data dumps, but I still have a lot of these unique queries of my SDE.
... View more
08-30-2010
06:19 AM
|
0
|
0
|
497
|
POST
|
** edit, just saw that last comment you posted above. In my experience, a Web Service is quick, easy and usually a great tool for accessing external data. You could create a web service using a .NET flavor of your choice that will query your SDE or any other db to simulate your relate. Pass it a name, id, whatever. It may be a little slow depending on size of results. I've used this method for a couple of years and it works fine. Typical method for above scenario. Select graphic on map (you could also do this after getting Identify results if you'd like) Pass attribute field value to web service Use service response to populate List/DataGrid A web service is pretty simple to set up in .NET and the code is pretty easy http://msdn.microsoft.com/en-us/library/8wbhsy70.aspx Simplest route is to return a DataTable and in flex that will be returned as an ArrayCollection that will look like event.result.Tables.<TableNameHere>.Rows A benefit of doing the queries this way is that you can perform any JOINS/UNIONS or changing of field names that you may want to pass to your application to make things easier on yourself.
... View more
08-27-2010
08:37 AM
|
0
|
0
|
497
|
POST
|
Relates won't work with 9.3.1 as the relationship is not recognized via the REST service.
... View more
08-27-2010
05:50 AM
|
0
|
0
|
497
|
POST
|
Widget is just another name for Module. The BaseWidget class that ESRI uses in FlexViewer extends Module and adds custom fields used in FlexViewer to pass data around. So if you are looking for info on Modules in general, look up how to work with Flex Modules, loading and unloading. This will help you figure out what is happening with widgets in FlexViewer. I don't think the FlexViewer unloads the widgets when they are closed. I think they get saved to a Dictionary object.
... View more
08-26-2010
02:18 PM
|
0
|
0
|
297
|
POST
|
If that doesn't solve your issue, are you doing compiling via ANT?
... View more
08-26-2010
12:27 PM
|
0
|
0
|
453
|
Title | Kudos | Posted |
---|---|---|
1 | 04-11-2022 10:39 AM | |
1 | 4 weeks ago | |
1 | 4 weeks ago | |
1 | 06-04-2024 01:15 PM | |
2 | 06-04-2024 08:28 AM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|