|
POST
|
In an application I've developed, I'm using the TOC control to let the user show the different layers of some different services. In addition to that, the user can click on the map to get an InfoWindow that contains the attributes of all the visible layers at that point. This InfoWindow contains tabs for each of the returned layers, with a datagrid of the features and their attributes. When the user rolls the mouse over the rows in the datagrid, I've added listeners to highlight the feature. Since these datagrids will vary with the different attributes, I'm building them each dynamically. That part works fine, but now my colleagues are asking for additional functionality. Some of the layers (but not all, of course) will have a field containing a URL and we want the user to be able to use that as a hyperlink. I've tried identifying the field that will usually contain the URL and set the ItemRenderer for that DataGridColumn using a component that was created by coder extraordinaire Robert Scheitlin but I'm getting the error "1067: Implicit coercion of a value of type Class to an unrelated type mx.core:IFactory" What am I doing wrong on this? And is there a way of finding the field that contains a URL (possibly by searching for the string "http:" in the result) without hard coding a field name (here, it's "Source")? Hers the result function from the IdentifyTask that I'm using to build the datagrids, tabs, and InfoWindow:
function resultFunction(results:Array, clickGraphic:Graphic):void
{
var myInfoRenderer:InfoRenderer = new InfoRenderer;
var mapPoint:MapPoint = MapPoint(clickGraphic.geometry);
var point:Point = map.toScreen(mapPoint);
if (results && results.length > 0)
{
var oldLayer:Number = -1;
var resultsArray:Array = [];
var result:IdentifyResult;
var resultGraphic:Graphic;
var tab:TabNavigator = new TabNavigator();
var newVBox:VBox = new VBox;
var newText:Text = new Text;
var newDG:DataGrid = new DataGrid;
var graphic:Graphic;
clickGraphicsLayer.add(clickGraphic);
result = results[0];
resultsArray.push(result.feature.attributes);
newText = new Text;
newText.text = result.layerName;
graphic = result.feature;
graphic.alpha = 0.3;
graphicsLayer.add(graphic);
tab.width = 400;
tab.height = 230;
for (var i:int = 1; i < results.length; i++)
{
result = results;
graphic = new Graphic;
graphic = result.feature;
graphic.alpha = 0.3;
graphicsLayer.add(graphic);
if (result.layerId == oldLayer)
{
resultsArray.push(result.feature.attributes);
}
else
{
newDG = new DataGrid;
newVBox = new VBox;
newDG.dataProvider = resultsArray;
//this is the new code section
if (!(result.feature.attributes.Source == undefined))
{
for each (var dgCol:DataGridColumn in newDG.columns)
{
if (dgCol.dataField == "Source")
{
dgCol.itemRenderer = HyperLinkField; //coercion error here
}
}
}
//end of new code section
newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true);
newVBox.addChild(newText);
newVBox.addChild(newDG);
tab.addChild(newVBox);
myInfoRenderer.addChild(tab);
newText = new Text;
newText.text = result.layerName;
resultsArray = [];
resultsArray.push(result.feature.attributes);
}
oldLayer = result.layerId
}
newVBox = new VBox;
newDG = new DataGrid;
newDG.addEventListener(ListEvent.ITEM_CLICK, newDG_ItemRollOver, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OUT, newDG_ItemRollOut, false, 0, true);
newDG.addEventListener(ListEvent.ITEM_ROLL_OVER, newDG_ItemRollOver, false, 0, true);
newVBox.addChild(newText);
newDG.dataProvider = resultsArray;
//this is the new code section
if (!(result.feature.attributes.Source == undefined))
{
for each (var dgCol:DataGridColumn in newDG.columns)
{
if (dgCol.dataField == "Source")
{
dgCol.itemRenderer = HyperLinkField;//coercion error here
}
}
}
//end of new code section
newVBox.addChild(newDG);
tab.addChild(newVBox);
myInfoRenderer.addChild(tab);
cursorManager.removeBusyCursor();
map.infoWindow.content = myInfoRenderer;
map.infoWindow.show(map.toMap(point));
map.infoWindow.addEventListener(Event.CLOSE,infoWindow_Close, false, 0, true);
}
}
... View more
11-30-2010
10:23 AM
|
0
|
2
|
1258
|
|
POST
|
Here's an example written in VB.NET, including the dissolve geoprocessor and the associated functions I use to get the results. The InputName object can be a string of the feature class's path, or an IFeatureClass. For the DissolveField and the StateFields syntax, I would recommend running the Dissolve tool manually and inspecting the syntax of the input message.
Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
Friend Function DissolveDataset(ByVal InputName As Object, ByVal DissolveField As String, ByVal StatsFields As String, ByVal OutputName As String) As ESRI.ArcGIS.Geodatabase.IFeatureClass
Dim DissolveDS As New ESRI.ArcGIS.DataManagementTools.Dissolve
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Try
DissolveDS.in_features = InputName
DissolveDS.dissolve_field = DissolveField
DissolveDS.statistics_fields = StatsFields
DissolveDS.out_feature_class = OutputName
Result = RunTool(DissolveDS, Nothing)
If Result Is Nothing Then
System.Windows.Forms.MessageBox.Show("Could not dissolve dataset")
Return Nothing
End If
Return ReturnFeatureClassfromResult(Result)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "Dissolve error")
Return Nothing
End Try
End Function
Friend Function ReturnFeatureClassfromResult(ByVal result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2) As ESRI.ArcGIS.Geodatabase.IFeatureClass
Dim GPVal As ESRI.ArcGIS.Geodatabase.IGPValue
Dim InMemFC As String
Dim GPUtil As ESRI.ArcGIS.Geoprocessing.IGPUtilities3 = New ESRI.ArcGIS.Geoprocessing.GPUtilities
Dim pOutputFC As ESRI.ArcGIS.Geodatabase.IFeatureClass
Try
GPVal = result.GetOutput(0)
InMemFC = GPVal.GetAsText()
pOutputFC = GPUtil.OpenFeatureClassFromString(InMemFC)
Return pOutputFC
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "Return FeatureClass error")
Return Nothing
End Try
End Function
Private Sub ReturnMessages(ByVal pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2, ByVal Title As String)
Dim ErrorMessage As String
If pResult.MessageCount > 0 Then
For Count As Integer = 0 To pResult.MessageCount - 1
ErrorMessage += pResult.GetMessage(Count)
Next
End If
System.Windows.Forms.MessageBox.Show(ErrorMessage, Title)
End Sub
Friend Function RunTool(ByVal Process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ESRI.ArcGIS.esriSystem.ITrackCancel2) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Try
Result = CType(GP.Execute(Process, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)
If Result.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then ReturnMessages(Result, "Geoprocessing Error")
GP.ClearMessages()
Catch ex As Exception
ReturnMessages(Result, "Fail")
System.Windows.Forms.MessageBox.Show(ex.ToString, "Run Geoprocessor")
End Try
Return Result
End Function
... View more
11-22-2010
07:22 AM
|
0
|
0
|
818
|
|
POST
|
Yes you can. I'm using 9.3.1 and the Flex API v1.3 on projects where I set the symbology with a renderer. The added step you'll have to take is to put the features on a graphic layer where they can be symbolized.
... View more
11-04-2010
05:22 AM
|
0
|
0
|
751
|
|
POST
|
You could use one of the Renderers to classify the colors and symbology for each of the features. For example, you could set up a class break renderer (see this sample) and change the attribute property of the renderer by using the field that the user chooses. You can get more complex by adding other renderers if you want to show different breaks for the species or using variables for the minValue and maxValue.
... View more
11-03-2010
12:38 PM
|
0
|
0
|
751
|
|
POST
|
We all forgot the final single quote
spatialFilter.WhereClause = "SECT = '" + featureID + "' AND RDIR = '" + RDIR + "' AND RNG = '" + RNG + "' AND TDIR = '" + TDIR + "' AND TWP = '" + TWP + "'";
... View more
11-02-2010
07:05 AM
|
0
|
0
|
892
|
|
POST
|
It looks like you're missing a few "AND"s
spatialFilter.WhereClause = "SECT = '" + featureID + "' AND RDIR = '" + RDIR + "' AND RNG = '" + RNG + "' AND TDIR = '" + TDIR + "' AND TWP = '" + TWP;
... View more
11-02-2010
06:43 AM
|
0
|
0
|
892
|
|
POST
|
Have you stepped through the code using the debugger? I would put a breakpoint at the If statement and check your variables to make sure you have properly read in the XML file. I've attached a screenshot of the XML list variable I get from my code. In this particular project, I'm not using the Extents node, but I've expanded out one of the nodes I am using (which also populates a combobox)
... View more
10-27-2010
11:56 AM
|
0
|
0
|
2569
|
|
POST
|
The first line in the try block (line 38) should be var loader:URLLoader = URLLoader(event.target)
... View more
10-27-2010
11:40 AM
|
0
|
0
|
2569
|
|
POST
|
I didn't show all of the init_onComplete function and left off the "catch" portion of the "try". Put this code before brace right before the the comment //Zoom to the Community tool...or just take out the "try" line
catch(e:Error)
{
Alert.show("Error: " + e.message);
return;
}
... View more
10-27-2010
10:48 AM
|
0
|
0
|
2735
|
|
POST
|
Here's the way I have it one of my applications. Once the XML file is finishing being read, if the XML file contains the extents node, I create an array that holds the extents and make that the dataprovider for my combobox cboExtent.
private var xmlParameters:XML;
public var xmlProjectParameters:XMLList;
private function init():void
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("parameters.xml"));
xmlLoader.addEventListener(Event.COMPLETE,init_onComplete);
}
private function init_onComplete(event:Event):void
{
var extentArray:ArrayCollection = new ArrayCollection;
try
{
var loader:URLLoader = URLLoader(event.target)
xmlParameters = new XML(loader.data)
xmlProjectParameters = xmlParameters.project.(@id=="Testing")
if (!(xmlParameters.extents == undefined))
{
cboExtent.visible = true;
for (var i:int = 0; i < xmlProjectParameters.extents.extent.length(); i++)
{
extentArray.addItem({label:xmlProjectParameters.extents.extent.@name.toString(), xmin: xmlProjectParameters.extents.extent.@xmin.toString(), ymin: xmlProjectParameters.extents.extent.@ymin.toString(), xmax: xmlProjectParameters.extents.extent.@xmax.toString(), ymax: xmlProjectParameters.extents.extent.@ymax.toString()});
}
cboExtent.dataProvider = extentArray;
}
This is what the Close event looks like for the combobox.
public function cboExtent_Close():void
{
var extent:Extent = new Extent(Number(cboExtent.selectedItem.xmin), Number(cboExtent.selectedItem.ymin), Number(cboExtent.selectedItem.xmax), Number(cboExtent.selectedItem.ymax))
mainMap.extent = extent;
}
and this is what the XML file looks like
<projects>
<project id="Testing">
<extents>
<extent name="Full Extent" xmin="-7389794" ymin="2023797" xmax="-7360030" ymax="2040131"/>
<extent name="Zoomin" xmin="-7370000" ymin="2030000" xmax="-7365000" ymax="2035000"/>
</extents>
</project>
</projects>
... View more
10-26-2010
11:53 AM
|
0
|
0
|
2735
|
|
POST
|
This should work
Dim pGxDialog As IGxDialog
Set pGxDialog = New GxDialog
pGxDialog.Title = "Select Catchments Feature Class"
pGxDialog.ButtonCaption = "Select"
pGxDialog.AllowMultiSelect = False
pGxDialog.StartingLocation = "Catalog"
Dim pGxFilter As IGxObjectFilter
Set pGxFilter = New GxFilterPolygonFeatureClasses
Set pGxDialog.ObjectFilter = pGxFilter
Dim pLayerFiles As IEnumGxObject
pGxDialog.DoModalOpen 0, pLayerFiles
Dim pLayerFile As IGxObject
Set pLayerFile = pLayerFiles.Next
Dim pFLayer As IFeatureLayer
Set pFLayer = New FeatureLayer
Set pFLayer.FeatureClass = pLayerFile.InternalObjectName.Open
Dim pFields As IFields
Set pFields = pFLayer.FeatureClass.Fields
Dim i As Integer
For i = 0 To pFields.FieldCount - 1
ComboBox1.AddItem pFields.Field(i).Name
Next
... View more
10-21-2010
08:12 AM
|
0
|
0
|
1187
|
|
POST
|
Is there any way the Flex API and Viewer for Flex forums could be listed closer together? There are a lot of Viewer related posts in the general forum, probably due to the fact that the Viewer forum is buried in the list of forums, whereas the API forum is at the top of a column. Related to this, can the moderators be more vigilant about moving posts into the correct forum?
... View more
10-13-2010
07:51 AM
|
0
|
0
|
2227
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 1 | 4 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 10-11-2023 06:18 AM | |
| 1 | 03-23-2026 09:23 AM |
| Online Status |
Offline
|
| Date Last Visited |
16 hours ago
|