POST
|
Hello, I've created some code that'll zoom to a feature queried from an ArcGIS Server Map Service, however now I want to flash the feature's geometry on the screen. I've grabbed the FlashGeometry snippet, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Flash_Geometry_Snippet/004900000075000000/ however nothing happens when I get to that portion of my code. I'm not sure what I'm missing, any suggestions would be appreciated. {
IGISServerConnection pGISServCon = new GISServerConnection();
pGISServCon.Connect("MyServer");
IServerObjectManager pSOM = pGISServCon.ServerObjectManager;
IServerContext pServerContext = pSOM.CreateServerContext("MyMapService", "MapServer");
IMapServer pMapServer = pServerContext.ServerObject as IMapServer;
IMapServerObjects pMapServerObjs = pMapServer as IMapServerObjects;
IMap pMap = pMapServerObjs.get_Map(pMapServer.DefaultMapName);
ILayer pFLayer = pMap.get_Layer(zoomMapServID) as ILayer;
IFeatureLayer pFeatlayer = pFLayer as IFeatureLayer;
IFeatureClass pFeatureClass = pFeatlayer.FeatureClass;
IQueryFilter pQfilt = new QueryFilterClass();
pQfilt.WhereClause = zoomColumn + " = '" + textBox1.Text + "'";
IFeatureCursor pFC = pFeatureClass.Search(pQfilt, false);
IFeature pFeat = pFC.NextFeature(); // all queries will return only 1 feature
IGeometry pGeom = pFeat.ShapeCopy as IGeometry;
IApplication pApp = ArcMap.Application;
IMxDocument pMxd = ArcMap.Document;
// Get the focus map
IMap map = pMxd.FocusMap;
// Cast from IMap to IActiveView
IActiveView pActiveview = (IActiveView)map;
IEnvelope pEnv = new EnvelopeClass();
//Set envelope to the geometry collection from the property below
pEnv = pGeom.Envelope;
//Create a new envelope to pass the values to from the geometry
IEnvelope envelope = new EnvelopeClass();
envelope.XMax = pEnv.Envelope.XMax;
envelope.YMax = pEnv.Envelope.YMax;
envelope.XMin = pEnv.Envelope.XMin;
envelope.YMin = pEnv.Envelope.YMin;
envelope.Expand(150, 150, false);
pActiveview.Extent = envelope;
pActiveview.Refresh();
pActiveview.ScreenDisplay.UpdateWindow();
//Setup parameters for FlashGeometry method
IRgbColor rgbColor = new RgbColorClass();
//Color Properties
rgbColor.Red = 133;
rgbColor.Green = 135;
rgbColor.Blue = 43;
IDisplay pDisplay = pActiveview.ScreenDisplay;
FlashGeometry(pGeom, rgbColor, pDisplay, 300);
} Flash Geometry Code, I removed the case statements for all other geometries other than polygon to shorten the code block. public void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor color, ESRI.ArcGIS.Display.IDisplay display, System.Int32 delay)
{
if (geometry == null || color == null || display == null)
{
return;
}
display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
switch (geometry.GeometryType)
{
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
{
//Set the flash geometry's symbol.
ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
simpleFillSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
//Flash the input polygon geometry.
display.SetSymbol(symbol);
display.DrawPolygon(geometry);
System.Threading.Thread.Sleep(delay);
display.DrawPolygon(geometry);
break;
}
}
display.FinishDrawing();
}
... View more
10-17-2011
02:04 PM
|
0
|
0
|
543
|
POST
|
Figured it out. I'm not sure if this is proper coding but it works. I created another envlope and passed the x and y's from the geometry bag. IEnvelope pEnv = new EnvelopeClass(); //Set envelope to the geometry collection from the method below pEnv = GeometryBag_Example(pFeatureClass, pQfilt).Envelope; // new code //Create a new envelope to pass the values to from the geometry bag IEnvelope envelope = new EnvelopeClass(); envelope.XMax = pEnv.Envelope.XMax; envelope.YMax = pEnv.Envelope.YMax; envelope.XMin = pEnv.Envelope.XMin; envelope.YMin = pEnv.Envelope.YMin; pActiveview.Extent = envelope; pActiveview.Refresh();
... View more
10-06-2011
02:56 PM
|
0
|
0
|
340
|
POST
|
Thank you for the reply, unfortunately the full Refresh method gets me the same results. The same can be said for adding an envelope variable in the PartialRefresh method. Any other suggestions? Todd
... View more
10-06-2011
08:21 AM
|
0
|
0
|
340
|
POST
|
Hello, I've created an Add-In that will zoom to a location in a user's map based off a selection from a layer in an AGS map service. Once the user inputs their criteria, ArcMap will zoom to that location, but it will not redraw the existing layers in their map. Any suggestions to get the existing map layers to draw would be greatly appreciated! IGISServerConnection pGISServCon = new GISServerConnection();
pGISServCon.Connect("myserver");
IServerObjectManager pSOM = pGISServCon.ServerObjectManager;
IServerContext pServerContext = pSOM.CreateServerContext("ZoomTools", "MapServer");
IMapServer pMapServer = pServerContext.ServerObject as IMapServer;
IMapServerObjects pMapServerObjs = pMapServer as IMapServerObjects;
IMap pMap = pMapServerObjs.get_Map(pMapServer.DefaultMapName);
ILayer pFLayer = pMap.get_Layer(zoomMapServID) as ILayer;
IFeatureLayer pFeatlayer = pFLayer as IFeatureLayer;
IFeatureClass pFeatureClass = pFeatlayer.FeatureClass;
IQueryFilter pQfilt = new QueryFilterClass();
//pQfilt.WhereClause = "QS_NUMBER = '23-55'";
pQfilt.WhereClause = zoomColumn + " = '" + textBox1.Text + "'";
IEnvelope pEnv = new EnvelopeClass();
//Set envelope to the geometry collection from the method below
pEnv = GeometryBag_Example(pFeatureClass, pQfilt).Envelope;
IMxDocument pMxd = ArcMap.Document;
// Get the focus map
IMap map = pMxd.FocusMap;
// Cast from IMap to IActiveView
IActiveView pActiveview = (IActiveView)map;
pActiveview.FullExtent = pEnv.Envelope;
//zooms to the right area on the map, but will not draw existing layers in the mxd.
pActiveview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
... View more
10-05-2011
03:02 PM
|
0
|
4
|
1063
|
POST
|
I've created an addin button that goes to an ArcGIS Server map service, selects a feature and then sets the geometry envelope of that feature to the activeview view extent in ArcMap. The code doesn't error out, but I can't seem to get the values for the new envelope to stick to the values of the activeview extent. Any ideas? private void button2_Click(object sender, EventArgs e) { IGISServerConnection pGISServCon = new GISServerConnection(); pGISServCon.Connect("CC1wa126"); IServerObjectManager pSOM = pGISServCon.ServerObjectManager; IServerContext pServerContext = pSOM.CreateServerContext("ZoomTest", "MapServer"); IMapServer pMapServer = pServerContext.ServerObject as IMapServer; IMapServerObjects pMapServerObjs = pMapServer as IMapServerObjects; IMap pMap = pMapServerObjs.get_Map(pMapServer.DefaultMapName); ILayer pFLayer = pMap.get_Layer(0) as ILayer; IFeatureLayer pFeatureClass = pFLayer as IFeatureLayer; IQueryFilter pQfilt = new QueryFilterClass(); pQfilt.WhereClause = "UTB_ACCOUNT = '031935'"; IFeatureCursor pFC = pFeatureClass.Search(pQfilt, false); IFeature pFeat = pFC.NextFeature(); // all queries will return only 1 feature IGeometry pGeom = pFeat.ShapeCopy; IEnvelope pEnv = new EnvelopeClass(); pEnv = pGeom.Envelope; IMxDocument pMxd = ArcMap.Document; IActiveView pActiveview = pMxd.ActiveView; pActiveview.Extent = pEnv;// pActiveview extent not updating to the envelope of pEnv pActiveview.Refresh(); }
... View more
09-27-2011
03:34 PM
|
0
|
0
|
1716
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|