private void zoomFromDataGrid(string sWhere) { //Set the query filter. use the arguements passed into the function IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = sWhere; ESRI.ArcGIS.ArcMapUI.IMxDocument pMxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument) this.App.Document; IMap pMap = (IMap)pMxDoc.FocusMap; IFeatureLayer pTaxlotLayer; using (CSpatialSubs oSpatialSubs = new CSpatialSubs()) { pTaxlotLayer = (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, SConst.Taxlots); oSpatialSubs.selectFeatures(pQueryFilter, this.App, pTaxlotLayer, true); } }
private void createDataFrame(string sMapName) { try { IMxDocument pMxDoc = (IMxDocument)ArcMap.Document; IMap pMap = new MapClass(); pMap.Name = sMapName; //Dictionary<string, string> dctMapLayers = Dictionary <string, string> dctMapLayers = new Dictionary <string, string>(); switch (sMapName.ToUpper()) { case "ECONOMIC DEVELOPMENT": dctMapLayers = SConst.EconDevLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_EconOnLayers); break; case "FIRE": dctMapLayers = SConst.FireLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_FireOnLayers); break; case "PLANNING": dctMapLayers = SConst.PlanningLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PlanOnLayers); break; case "POLICE": dctMapLayers = SConst.PoliceLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PoliceOnLayers); break; case "PUBLIC WORKS": dctMapLayers = SConst.PublicWorksLayers; this.loadLayers(ref pMap, dctMapLayers, this.m_PWOnLayers); break; default: return; } //addMapLayers(ref pMap, sMapName); IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(1, 1, 5, 4); // page units pMxDoc.Maps.Add(pMap); IMapFrame pMapFrame = this.MakeMapFrame(pEnv, pMap); pMapFrame.Map.MapUnits = esriUnits.esriFeet; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; pGC.AddElement((IElement)pMapFrame, 0); pMxDoc.CurrentContentsView.Refresh(null); pMxDoc.UpdateContents(); Application.DoEvents(); // activate the frame and zoom to the extent of the UGB for (int i = 0; i < pMxDoc.Maps.Count; i++) { IMap map = pMxDoc.Maps.get_Item(i); if (map.Name == sMapName) { pMxDoc.ActiveView = (IActiveView)map; //Set the query filter. use the arguements passed into the function ESRI.ArcGIS.Geodatabase.IQueryFilter pQueryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); pQueryFilter.WhereClause = "CITY = 'Medford'"; using (CSpatialSubs oSpatialSubs = new CSpatialSubs()) { oSpatialSubs.selectFeatures(pQueryFilter, this.App, (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, "MEDSDE.DBO.Urban_Growth_Boundary"), true); } pMxDoc.FocusMap.ClearSelection(); } } pMxDoc.UpdateContents(); Application.DoEvents(); } catch (Exception ex) { string s = ex.Message; s += ex.InnerException.Message; s += " "; } }