MapWinGIS:AxMap Extents

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

Extents

Gets or sets the extents of the map using an Extents object. If the given extents do not fit the aspect ratio of the map, the map will fit the given extents as well as possible.


VB.NET Usage

Property Extents() As Object

            Parameters

ReturnValue

The extents of the map as represented by an Extents object.

Sample Code

    Private Sub ExtentsExample()
        Dim image As New MapWinGIS.Image()
        Dim extents As MapWinGIS.Extents
        Dim hndl As Integer
        'Set extents to the current extents of the map
        extents = CType(Map1.Extents, MapWinGIS.Extents)
        'Set the image to a snapshot of what is currently displayed in the map
        image = Map1.SnapShot(extents)
        'Remove all layers in the map
        Map1.RemoveAllLayers()
        'Add the snapshot taken above to the map as a new layer
        hndl = Map1.AddLayer(image, True)
    End Sub
  

VB 6 Usage
Property Extents() As Object
            Parameters

ReturnValue

The extents of the map as represented by an Extents object.

Sample Code

    Private Sub ExtentsExample()
        Dim image As New MapWinGIS.image
        Dim extents As MapWinGIS.extents
        Dim hndl As Long
        'Set extents to the current extents of the map
        Set extents = Map1.extents
        'Set the image to a snapshot of what is currently displayed in the map
        Set image = Map1.SnapShot(extents)
        'Remove all layers in the map
        Map1.RemoveAllLayers
        'Add the snapshot taken above to the map as a new layer
        hndl = Map1.AddLayer(image, True)
    End Sub


The following VB6 example shows how to modify the extents and reassign them to a map. It centres the map around a specified XY coordinate pair, retaining the current zoom level.

   Sub CentreMapOnXY(pxCentre As Double, pyCentre As Double)
   Dim ext As MapWinGIS.extents
   Dim xRange2 As Double
   Dim yRange2 As Double
       Set ext = axMap.extents
       xRange2 = (ext.xMax - ext.xMin) / 2
       yRange2 = (ext.yMax - ext.yMin) / 2
       ext.SetBounds pxCentre - xRange2, pyCentre - yRange2, 0, pxCentre + xRange2, pyCentre + yRange2, 0    
       Set axMap.extents = ext
   End Sub

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS:AxMap_Extents"

This page has been accessed 3,011 times. This page was last modified on 1 December 2007, at 16:14.