ESRI can be as frustrating as it can get. My lack of experience with ASP.NET 2.0/3.0 combined with the vast differences betwen the desktop functionality of ArcGIS and the web functionality of ArcIMS / WebADF is giving me gray hair faster then my kids every could dream of doing.
I have a .NET pretty much out of the box site - that is, I went into "ArcIMS Web Manager for the Microsoft .NET Framework" and setup a new site. I have some queries that had to be customized, and I ran out of time trying to get the TaskResults panel to display the query results (I'll post about that experience when I have a little more time), so I put them in an HTML table in their own panel. I have a hyperlink in the table which, when clicked, should zoom to that feature on the map. I have looked and, and am using some code from this thread how can i zoom to my selected features - only it isn't working fully.
I am getting new envelope for the feature, and I am setting the map extents to that envelope. I know this works because I put some dummy code in a Map1_ExtentsChanged event handler and checked to ensure the map extents were changed. Then I hit Map1.Refresh(); but the map does not change. I'm returning the Map1.CallBackResults.ToString();, but I'm ignorant of what to do with the results on the client side. The RaiseCallbackEvent method returns the 'response' string.
After playing around and doing some more searching with different keywords, I found this thread; The ESRI Map control does not refresh ..... which talks about client side map.redraw(); giving the following example:
I thought this would solve my problem and it almost-but-not-quite does. It does redraw the map (at least it looks like it does). But what I get is a completely blank map until I either zoom in or out. Then the map appears zoomed to roughly the correct location (depending on if I zoomed in or out to make it show up). Also works using the mouse wheel.
Technorati Tags: ESRI, WebADF, ArcIMS, ASP.NET, C#
I have a .NET pretty much out of the box site - that is, I went into "ArcIMS Web Manager for the Microsoft .NET Framework" and setup a new site. I have some queries that had to be customized, and I ran out of time trying to get the TaskResults panel to display the query results (I'll post about that experience when I have a little more time), so I put them in an HTML table in their own panel. I have a hyperlink in the table which, when clicked, should zoom to that feature on the map. I have looked and, and am using some code from this thread how can i zoom to my selected features - only it isn't working fully.
// This is the method to zoom to the feature, param 'key' is the objectid of the feature, and the param 'layer' is the name of the feature layer
protected void ZoomToFeature(string key, string layer)
{
ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality mf;
ESRI.ArcGIS.ADF.IMS.Carto.MapView mv;
mf = (ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)Map1.GetFunctionality(0);
mv = mf.MapView;
ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureLayer queryLayer;
queryLayer = (FeatureLayer)mv.Layers.FindByName(layer);
Filter queryFilter = new Filter();
QueryParameters queryParams = new QueryParameters(queryFilter);
queryFilter.WhereExpression = "ObjectID = '" + key + "'";
queryFilter.Tolerance = 20;
queryFilter.ToleranceUnits = BufferUnits.Meters;
queryParams.ReturnGeometries = true;
queryParams.ReturnGlobalEnvelope = true;
ESRI.ArcGIS.ADF.IMS.Display.Symbol.FeatureSymbol fs = new ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleFillSymbol(System.Drawing.Color.White, System.Drawing.Color.Red, ESRI.ArcGIS.ADF.IMS.Display.Symbol.PolygonFillType.Solid);
ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer sr = new ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer(fs);
queryLayer.Visible = true;
FeatureTable ft = queryLayer.Query(queryParams);
if (ft.Rows.Count > 0)
{
ESRI.ArcGIS.ADF.IMS.Geometry.Geometry featureGeom = (ESRI.ArcGIS.ADF.IMS.Geometry.Geometry)ft.Rows[0]["#SHAPE#"];
ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfGEom = ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(featureGeom);
ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnv = ESRI.ArcGIS.ADF.Web.Geometry.Envelope.GetMinimumEnclosingEnvelope(adfGEom);
Map1.Extent = adfEnv;
}
Map1.Refresh();
}
// This is the code in RaiseCallbackEvent(string responseString) method which calls the ZoomToFeature method
this.ZoomToFeature(eventArg, layerArg);
response = Map1.CallbackResults.ToString();
I am getting new envelope for the feature, and I am setting the map extents to that envelope. I know this works because I put some dummy code in a Map1_ExtentsChanged event handler and checked to ensure the map extents were changed. Then I hit Map1.Refresh(); but the map does not change. I'm returning the Map1.CallBackResults.ToString();, but I'm ignorant of what to do with the results on the client side. The RaiseCallbackEvent method returns the 'response' string.
After playing around and doing some more searching with different keywords, I found this thread; The ESRI Map control does not refresh ..... which talks about client side map.redraw(); giving the following example:
var map = Maps['<%=Map1.ClientID %>'];
map.redraw();
I thought this would solve my problem and it almost-but-not-quite does. It does redraw the map (at least it looks like it does). But what I get is a completely blank map until I either zoom in or out. Then the map appears zoomed to roughly the correct location (depending on if I zoomed in or out to make it show up). Also works using the mouse wheel.
Technorati Tags: ESRI, WebADF, ArcIMS, ASP.NET, C#