Hello,
So I have a project I inherited and I want to build a zoom extent button for each TPK that is loaded. I have created the zoom button next to the delete button for each loaded TPK and the delete option works but the zoom extent does not. I was wondering if I could get a little help because I cannot seem to get the zoom extent property. Below is the code:
public void ZoomToLayer(bool fromSelection)
{
if (esriMap != null && _selectedLayer != null && fromSelection)
{
// Get selected layer
MapPageLayers subFile = (MapPageLayers)_selectedLayer;
string localLayerPath = Path.Combine(accessData.ProjectPath, subFile.LayerName);
//For tpks
if (!subFile.LayerName.Contains("sql"))
{
Layer foundLayer = null;
// Find the layer from the image layer
foreach (Layer l in esriMap.AllLayers)
{
if (l.Name == subFile.LayerName.Split('.')[0])
{
foundLayer = l;
break;
}
}
if (foundLayer != null)
{
//Zoom to extent of Layer
esriMap.Basemap.Item.Extent = foundLayer.FullExtent;
}
//Reset layer and layer flyout
_selectedLayer = string.Empty;
}
else
{
//Zoom to extent of Layer
esriMap.Basemap.Item.Extent = foundLayer.FullExtent;
//Reset layer and layer flyout
_selectedLayer = string.Empty;
}
}
}
}
Now This code works for deleting a tpk map layer but I tried to get the zoom extent feature of the layer and cannot because I am not an expert coder at all. Does anyone know how to do this? The code in red is the code that gives me issues.