Jul 28, 2012 at 1:01 AM
Edited Jul 28, 2012 at 1:02 AM
|
Sorry if such an elementary thing has been covered but I searched and searched and couldn't find it. How can I zoom to the extent of a layer?
What I'm looking for is something like
but that obviously doesn't exist.
|
|
Jul 28, 2012 at 1:16 AM
Edited Jul 28, 2012 at 1:17 AM
|
Hi,
Here goes some code:
foreach (IMapLayer lay in map1.GetAllLayers())
{
if (lay != null)
{
if (lay.IsSelected == true)
{
//gets the SelectedLayer
var layer = map1.Layers.SelectedLayer;
if (layer != null)
map1.ViewExtents = layer.DataSet.Extent;
}
else
{
//if lay is not selected, ask the user to select (highlight) some layer
MessageBox.Show("Selecione uma Camada.");
}
}
else
{
//if lay is null, ask the user to add some layer
MessageBox.Show("Adicione uma Camada.");
}
}
Regards,
Evemar
|
|
|
|
Thanks.
|
|
|
|
well, can you test the function with the layer of mappointlayer which has only one point feature, i test it and there is no exception but show nothing on the map , it seems that the point feature disappear! can you tell me a tips or give me some example
code, i will very appreciate with your help!
|
|
|
|
Hi,
I have tested that and when I make zoom to a point layer with only one point, it raises an exception.
I will investigate and try some workaround.
Regards,
Evemar
|
|