|
POST
|
The link is in my posting above. Click on the word "blog". Here's the link to the post itself.
... View more
08-12-2010
07:43 AM
|
0
|
0
|
727
|
|
POST
|
I'm running into a problem when attempting to see the graphicprovider for a graphic layer to show the results of an IdentifyTask in my program. I'm adding the graphic layer (along with a bunch of other layers) in the initialize code for the page. I tried using the Identify sample from the Resource page (version 1.3) to run a test. When I click on a polygon with the original sample code, the polygon gets shaded with the symbology as expected. However, when I programmatically add in the graphic layer holding the lastIdentifyResultGraphic, the polygon does not get shaded as expected. Where am I going wrong in this code?
<?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"
layout="vertical"
styleName="plain"
pageTitle="Identify Features on the Map" initialize="init();">
<!--
This sample shows how to identify features with a MapClick and the Identify task.
The IdentifyParameters designate which layers are being identified.
Identify operations can potentially return a lot of information
depending on the number of layers being identified and a given tolerance.
The tolerance is the number of pixels a feature is allowed to lie away
from the clicked point in order to be counted as a result.
In this sample, when user clicks the map, an "Identify" task is executed.
When the task finishes executing, the identifyCompleteHandler function loops
through the features in the IdentifyResult and adds them to the map.
-->
<mx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.symbol.InfoSymbol;
import com.esri.ags.tasks.IdentifyParameters;
import com.esri.ags.tasks.IdentifyResult;
import mx.controls.Alert;
import mx.rpc.AsyncResponder;
[Bindable]
private var lastIdentifyResultGraphic:Graphic;
private var layerGraphics:GraphicsLayer = new GraphicsLayer;
private function init():void
{
layerGraphics.graphicProvider = lastIdentifyResultGraphic;
myMap.addLayer(layerGraphics);
}
private function mapClickHandler(event:MapMouseEvent):void
{
clickGraphicsLayer.clear();
var identifyParams:IdentifyParameters = new IdentifyParameters();
identifyParams.returnGeometry = true;
identifyParams.layerIds = new Array([2]);
identifyParams.tolerance = 3;
identifyParams.width = myMap.width;
identifyParams.height = myMap.height;
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = myMap.extent;
identifyParams.spatialReference = myMap.spatialReference;
var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
clickGraphicsLayer.add(clickGraphic);
}
private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
{
if (results && results.length > 0)
{
var result:IdentifyResult = results[0];
var resultGraphic:Graphic = result.feature;
switch (resultGraphic.geometry.type)
{
case Geometry.MAPPOINT:
{
resultGraphic.symbol = smsIdentify;
break;
}
case Geometry.POLYLINE:
{
resultGraphic.symbol = slsIdentify;
break;
}
case Geometry.POLYGON:
{
resultGraphic.symbol = sfsIdentify;
break;
}
}
lastIdentifyResultGraphic = resultGraphic;
// update clickGraphic (from mouse click to returned feature)
clickGraphic.symbol = new InfoSymbol(); // use default renderer
clickGraphic.attributes = resultGraphic.attributes;
}
}
private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
{
Alert.show(String(error), "Identify Error");
}
]]>
</mx:Script>
<!-- start declarations -->
<!-- Symbol for where the user clicked -->
<esri:SimpleMarkerSymbol id="clickPtSym" style="x" color="0xFF0000" size="12"/>
<!-- Symbol for Identify Result as Polyline -->
<esri:SimpleLineSymbol id="slsIdentify" style="solid" color="0x00FF00" width="2" alpha="1"/>
<!-- Symbol for Identify Result as Point -->
<esri:SimpleMarkerSymbol id="smsIdentify" style="diamond" color="0x00FF00" size="15"/>
<!-- Symbol for Identify Result as Polygon -->
<esri:SimpleFillSymbol id="sfsIdentify"/>
<!-- Identify Task -->
<esri:IdentifyTask id="identifyTask"
concurrency="last"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/>
<!-- end declarations -->
<esri:Map id="myMap" mapClick="mapClickHandler(event)">
<esri:extent>
<esri:Extent xmin="-120" ymin="30" xmax="-100" ymax="50">
<esri:SpatialReference wkid="4326"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer
url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
<!--<esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>-->
<esri:GraphicsLayer id="clickGraphicsLayer"/>
</esri:Map>
</mx:Application>
... View more
08-06-2010
01:08 PM
|
0
|
2
|
901
|
|
POST
|
You can develop an msi on a machine with a previous version of ArcGIS (say, 9.2) and have it deployed on machine with later service packs or even versions. I have developed several in 9.2 that were used in 9.3. However, you will run into problems when going the other way. The target machine cannot have an previous service pack or version than the development machine. Take a look at this thread to see some discussion on how to check the target machine for the version and service pack, and whether the ArcGIS .NET Assemblies are installed. In my posting in that thread, I was just allowing for deployment on an ArcGIS 9.2 machine. Here are the conditions for a project developed in ArcGIS 9.2, service pack 6 that can be deployed on later machines. The only case where it doesn't work properly is when the machine has ArcGIS 9.2 with no service pack. I couldn't find a way to flag that circumstance while allowing installation on ArcGIS 9.3 with no service pack. Under "Launch Conditions" (Name) - ArcGIS Service Pack Condition - (SP<>"9.2.0.1324")and(SP<>"9.2.1.1332")and(SP<>"9.2.2.1350")and(SP<>"9.2.3.1380")and(SP<>"9.2.4.1420")and(SP<>"9.2.5.1450") InstallURL - Message - This installer is only for ArcGIS 9.2, Service Pack 6 or higher. (Name) - ArcGIS Condition - (VERSION="9.2")or(VERSION="9.3") InstallUrl - Message - This installer only runs for ArcGIS 9.2 or higher.
... View more
08-05-2010
11:03 AM
|
0
|
0
|
1478
|
|
POST
|
If you notice in the Form_Initialize code, it's expecting IApplication to be passed to it. Here's the OnCreate and OnClick subroutines. I'm also using a a class that sets ArcMap as the form's parent, as mentioned in this thread.
Private m_application As IApplication
Public Overrides Sub OnCreate(ByVal hook As Object)
If Not hook Is Nothing Then
m_application = CType(hook, IApplication)
'Disable if it is not ArcMap
If TypeOf hook Is IMxApplication Then
MyBase.m_enabled = True
Else
MyBase.m_enabled = False
End If
End If
' TODO: Add other initialization code
End Sub
Public Overrides Sub OnClick()
Dim SelectionForm As New myApp.SelectionForm
Try
If Not SelectionForm.Form_Initialize(m_application) Then Exit Sub
SelectionForm.ShowDialog(New Win32HWNDWrapper(m_application.hWnd))
Catch ex As Exception
MessageBox.Show(ex.Message, "OnClick")
End Try
End Sub
... View more
08-03-2010
11:09 AM
|
0
|
0
|
763
|
|
POST
|
Here's a function I've used in creating featureclasses. I use the IGXDialog.DoModalSave to get the parameters to send to the function, along with the fields that were created. In this code, I'm creating the fields from an existing dataset (pPointFLayer) and also use its spatial reference to create a line featurelayer.
dim OutputLocation As String
dim OutputFCName As String
dim GDBType As String
Dim pGxDialog As ESRI.ArcGIS.CatalogUI.IGxDialog = New ESRI.ArcGIS.CatalogUI.GxDialog
Dim pShapeFilter As ESRI.ArcGIS.Catalog.IGxObjectFilter = New ESRI.ArcGIS.Catalog.GxFilterShapefiles
Dim pPGDBFilter As ESRI.ArcGIS.Catalog.IGxObjectFilter = New ESRI.ArcGIS.Catalog.GxFilterPGDBFeatureClasses
Dim pFilterCollection As ESRI.ArcGIS.Catalog.IGxObjectFilterCollection
Dim pGeoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset
Dim pSR As ESRI.ArcGIS.Geometry.ISpatialReference
Dim pSpatRes As ESRI.ArcGIS.Geometry.ISpatialReferenceResolution
Dim pFields As ESRI.ArcGIS.Geodatabase.IFields = New ESRI.ArcGIS.Geodatabase.Fields
Dim pFieldsEdit As ESRI.ArcGIS.Geodatabase.IFieldsEdit
Dim pField As ESRI.ArcGIS.Geodatabase.IField
Dim pFieldEdit As ESRI.ArcGIS.Geodatabase.IFieldEdit
Dim pGeomDefEdit As ESRI.ArcGIS.Geodatabase.IGeometryDefEdit = New ESRI.ArcGIS.Geodatabase.GeometryDef
Dim pClone As ESRI.ArcGIS.esriSystem.IClone
Dim pLineFLayer As ESRI.ArcGIS.Carto.IFeatureLayer = New ESRI.ArcGIS.Carto.FeatureLayer
pGxDialog.Title = "Output Feature Class Name"
pFilterCollection = pGxDialog
pFilterCollection.AddFilter(pPGDBFilter, True)
pFilterCollection.AddFilter(pShapeFilter, False)
If pGxDialog.DoModalSave(0) Then
OutputLocation = pGxDialog.FinalLocation.FullName
OutputFCName = pGxDialog.Name
GDBType = pGxDialog.FinalLocation.Category
End If
pGeoDataset = pPointFLayer
pSR = pGeoDataset.SpatialReference
pSpatRes = pSR
pSpatRes.ConstructFromHorizon()
'create the geometry field
With pGeomDefEdit
.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline
.HasM_2 = False
.HasZ_2 = False
.SpatialReference_2 = pSR
End With
'Create fields for output FC
pFieldsEdit = pFields
pField = New ESRI.ArcGIS.Geodatabase.Field
pFieldEdit = pField
With pFieldEdit
If GDBType = "Folder" Then
.Name_2 = "FID"
Else
.Name_2 = "ObjectID"
End If
.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID
End With
pFieldsEdit.AddField(pField)
pFieldsEdit = pFields
pField = New ESRI.ArcGIS.Geodatabase.Field
pFieldEdit = pField
With pFieldEdit
.Name_2 = "SHAPE"
.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry
.GeometryDef_2 = pGeomDefEdit
End With
pFieldsEdit.AddField(pField)
For i As Integer = 0 To pPointFLayer.FeatureClass.Fields.FieldCount - 1
If pPointFLayer.FeatureClass.Fields.Field(i).Type < 6 Then
pClone = pPointFLayer.FeatureClass.Fields.Field(i)
pFieldsEdit.AddField(pClone.Clone)
End If
Next
pLineFLayer.FeatureClass = CreateFeatureClass(OutputLocation, OutputFCName, GDBType, pFields)
Friend Function CreateFeatureClass(ByVal WorkSpaceName As String, ByVal DatasetName As String, ByVal GDBType As String, ByVal pFields As ESRI.ArcGIS.Geodatabase.IFields) As ESRI.ArcGIS.Geodatabase.IFeatureClass
Dim pWSFactory As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory
Dim pFWSpace As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace
Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset
Try
Select Case GDBType 'the values for this vary with the computer's localization. This is the English language version.
Case "Folder"
pWSFactory = New ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory
Case "Personal Geodatabase"
pWSFactory = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory
Case "File Geodatabase"
pWSFactory = New ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory
Case Else
System.Windows.Forms.MessageBox.Show("Incorrect GDBType!", "", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
Return Nothing
End Select
pFWSpace = pWSFactory.OpenFromFile(WorkSpaceName, 0)
Try
pDataset = pFWSpace.OpenFeatureClass(DatasetName)
Catch ex As Exception
'do nothing here
End Try
If Not pDataset Is Nothing Then
If pDataset.CanDelete Then
pDataset.Delete()
Else
System.Windows.Forms.MessageBox.Show("Cannot delete existing dataset " & pDataset.Name)
Return Nothing
End If
End If
Return pFWSpace.CreateFeatureClass(DatasetName, pFields, Nothing, Nothing, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, "Shape", "")
Catch ex As Exception
MessageBox.Show(ex.Message)
Return Nothing
End Try
End Function
... View more
08-03-2010
10:57 AM
|
0
|
0
|
536
|
|
POST
|
In this example, I have a form with two comboboxes. The first (cboPointLayer) contains the point layers in the view and the second (cboField) contains the fields of the selected layer. The Form_Initialize function populates cboPointLayer and when the user selects a layer, the subroutine cboPointLayer_SelectedIndexChanged populates cboField.
Public Class SelectionForm
Private m_App As ESRI.ArcGIS.Framework.IApplication
Private pMxDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument
Private pEnumLayers As ESRI.ArcGIS.Carto.IEnumLayer
Private pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer
Friend Function Form_Initialize(ByVal m_application As ESRI.ArcGIS.Framework.IApplication) As Boolean
Dim pLayer As ESRI.ArcGIS.Carto.ILayer
Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer2
m_App = m_application
pMxDoc = CType(m_App.Document, ESRI.ArcGIS.ArcMapUI.IMxDocument)
cboPointLayer.Items.Clear()
cboField.Items.Clear()
If pMxDoc.FocusMap.LayerCount > 0 Then
pEnumLayers = pMxDoc.FocusMap.Layers
pLayer = pEnumLayers.Next
Do Until pLayer Is Nothing
If pLayer.Valid Then
If TypeOf pLayer Is ESRI.ArcGIS.Carto.IFeatureLayer Then
pFLayer = pLayer
If pFLayer.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint Then
cboPointLayer.Items.Add(pLayer.Name)
End If
End If
End If
pLayer = pEnumLayers.Next
Loop
End If
Return True
End Function
Private Sub cboPointLayer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPointLayer.SelectedIndexChanged
Dim pLayer As ESRI.ArcGIS.Carto.ILayer
Dim pFields As ESRI.ArcGIS.Geodatabase.IFields
Try
pEnumLayers.Reset()
cboField.Items.Clear()
pLayer = pEnumLayers.Next
Do Until pLayer Is Nothing
If pLayer.Name = cboPointLayer.Text Then
pPointFLayer = New ESRI.ArcGIS.Carto.FeatureLayer
pPointFLayer = pLayer
Exit Do
End If
pLayer = pEnumLayers.Next
Loop
pFields = pPointFLayer.FeatureClass.Fields
For i As Integer = 0 To pFields.FieldCount - 1
If pFields.Field(i).Type < 6 Then 'this adds only numeric, date, and string fields, not geometry, Blobs, raster, GUID, Global ID, or XML fields.
cboField.Items.Add(pFields.Field(i).Name)
ListBox1.Items.Add(pFields.Field(i).Name)
End If
Next
EnableRun()
Catch ex As Exception
Messagebox.Show(ex.message, "Point Layer")
End Try
End Sub
End Class
... View more
08-03-2010
09:28 AM
|
0
|
0
|
763
|
|
POST
|
Take a look at this thread for alternate code to determine the type of an object from IGXObject. One problem I ran into when using IGxObject.Category is that the values are localized. For example, I wrote an application that worked perfectly fine on English language machines, but crashed in other languages. In my code, I was checking the type of table that was selected by a user. If I select a dbf file, this code will return a ShapefileWorkspaceFactoryClass.
Select Case pGxObj.Category
Case "Personal Geodatabase Table"
pFact = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass
Case "File Geodatabase Table"
pFact = New ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass
Case "dBASE Table"
pFact = New ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass
Case "SDC Feature Class"
pFact = New ESRI.ArcGIS.DataSourcesFile.SDCWorkspaceFactoryClass
Case "SDE Table"
pFact = New ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory
Case Else
System.Windows.Forms.MessageBox.Show("Data type '" & pGxObj.Category & "' has not been coded yet...")
End Select
However, when a user with a German language machine selected a dbf file, he reported getting the error message "Data type 'dBASE-Tabelle' has not been coded yet".
... View more
07-27-2010
08:03 AM
|
0
|
0
|
887
|
|
POST
|
You have your quotes in the wrong place. Try this for your whereclause: pQf.WhereClause = "PHOTO_NO = " & frmRamp.txtPhoto.Text & " And WARD =" & frmRamp.txtWard.Text
... View more
07-22-2010
01:35 PM
|
0
|
0
|
443
|
|
POST
|
Keep an eye on Mansour's blog. He said he would be posting about this in the near future.
... View more
07-19-2010
06:00 AM
|
0
|
0
|
727
|
|
POST
|
Here's a better illustration of the arrows not appearing initially. And as I refresh the Firefox view, I'm seeing the same issue
... View more
07-07-2010
06:22 AM
|
0
|
0
|
2313
|
|
POST
|
This also happens once in Google Chrome on the first time, but not on refresh. I've been noticing that the tool bar is not consistently appearing in IE7 (we're not able to upgrade to 8 yet). Sometimes, the arrows to move the icons do not appear until I move the cursor over the map (filling in the X,Y coordinates) or resize the window. This is very intermittent.
... View more
07-07-2010
06:19 AM
|
0
|
0
|
2314
|
|
POST
|
It's coming up with a different error now. The message Error #1009 flashes briefly, then disappears. The empty error window remains. This happens on Firefox 3.6.6 (upgraded last night) every time I refresh it and once on IE7, but not on subsequent refreshes.
... View more
07-07-2010
06:04 AM
|
0
|
0
|
2314
|
|
POST
|
Ken, Thanks for the headsup I was able to get this error in IE 7 when I got home on a slower internet connection...? IE 7 must be do things in a strange order as the offending line of code what just a simple line telling the graphicsLayer to be visible. Hum... Anyway I have put some checks in there now to be sure the graphicsLayer for all my widgets that use graphicsLayers are not null before I try to use them. Hi Robert, I was getting this on Firefox 3.6.3 with Flash 10,1,53,64 and a high speed connection
... View more
07-07-2010
05:24 AM
|
0
|
0
|
2314
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 2 | 3 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | a month ago |
| Online Status |
Online
|
| Date Last Visited |
3 hours ago
|