VDS Technologies

 

zoom extent points

8/2/2015 8:03:39 AM
Total Posts 33

zoom extent points

Dear aspmap,

how to get zoom extent points layer automatically and without put zoomlevel ?

i try to put some code zoom extent  in a button,but still doesnt works, my code below

the Map11["locations"] is a PointDataLayer from mdb

protected void btnzoompoints_Click(object sender, EventArgs e)
{
if (Map11.FindLayer("locations") != null)
{
AspMap.Recordset rs = Map11["locations"].Recordset;
if (!rs.EOF)
{
AspMap.Rectangle extent = new AspMap.Rectangle();
AspMap.Point njak = new AspMap.Point();
extent.Left = Map11.CoordinateSystem.FromWgs84(rs.Extent).Left;
extent.Top = Map11.CoordinateSystem.FromWgs84(rs.Extent).Top;
extent.Right = Map11.CoordinateSystem.FromWgs84(rs.Extent).Top;
extent.Bottom = Map11.CoordinateSystem.FromWgs84(rs.Extent).Bottom;
Map11.Extent = Map11.CoordinateSystem.FromWgs84(extent);
njak = Map11.CoordinateSystem.FromWgs84(rs.Extent).Center;

Map11.CenterAt(Map11.CoordinateSystem.FromWgs84(njak));
Map11.ZoomLevel = 4;

}
}

}

 

thanks

 

8/8/2015 12:00:30 AM
MVP
Total Posts 323

Re: zoom extent points

The best way for you case is to use the Layer.Extent property

extent = Map11["locations"].Extent;

Map11.Extent = Map11.CoordinateSystem.FromWgs84(extent);

Or the CenterAndZoom method

extent = Map11["locations"].Extent;

Map11.CenterAndZoom(Map11.CoordinateSystem.FromWgs84(extent.Center), 4);

 

8/12/2015 10:58:46 PM
Total Posts 33

Re: zoom extent points

Ok thanks.