MapWinGIS:AxMap GetObject

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

GetObject

Returns the layer object with the given handle. The object could be a Shapefile, Grid, or Image object.
See also Shapefile and Grid and Image


VB.NET Usage

Property get_GetObject(LayerHandle As Integer) As Object

            Parameters

LayerHandle

The handle of the layer to be retrieved.
ReturnValue A Shapefile, Grid, or Image object.

Sample Code

    Private Sub GetObject()
        Dim hndl As Integer
        Dim obj As Object
        Dim sh As MapWinGIS.Shapefile
        Dim image As MapWinGIS.Image
        'Get handle for layer at position 0 in map
        hndl = Map1.get_LayerHandle(0)
        'Get the object in the specified layer
        obj = Map1.get_GetObject(hndl)
        'Display the type of object in a message box
        MsgBox(System.Convert.ToString(obj.GetType()))
        'Check if the object in the layer is a Shapefile
        If System.Convert.ToString(obj.GetType()) = "MapWinGIS.ShapefileClass" Then
            'If the object in the layer is a Shapefile, store it in our shapefile variable
            sh = Map1.get_GetObject(hndl)
        Else
            'If the object in the layer is not a Shapefile, store it in our image variable
            image = Map1.get_GetObject(hndl)
        End If
    End Sub
  

VB 6 Usage
Property GetObject(LayerHandle As Long) As Object
            Parameters

LayerHandle

The handle of the layer to be retrieved.
ReturnValue A Shapefile, Grid, or Image object.

Sample Code

    Private Sub GetObject()
        'This function assumes you have added a Shapefile to the map as the only layer
        Dim hndl As Long
        Dim sh As MapWinGIS.Shapefile
        Dim image As MapWinGIS.image, image2 As MapWinGIS.image
        Dim extents As MapWinGIS.extents
        'Get handle for layer at position 0 in map
        hndl = Map1.LayerHandle(0)
        'Get the Shapefile in the specified layer
        Set sh = Map1.GetObject(hndl)
        '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)
        'Get the image in the specified layer
        Set image2 = Map1.GetObject(hndl)
    End Sub

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

This page has been accessed 2,783 times. This page was last modified on 9 November 2005, at 18:54.