MapWinGIS:AxMap AddLayer

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

AddLayer

Adds a layer to the map.


VB.NET Usage

Function AddLayer(Object As Object, Visible As Boolean) As Integer

            Parameters

Object

The object (Image or Shapefile) to add to the map.
Visible Sets whether the layer is visible after being added to the map.

Return Value

Returns the integer handle for the layer added to the map.

Sample Code

    Private Sub AddLayerToMap()
        'Add Shapefile to Map
        Dim hnd As Integer
        Dim sf As MapWinGIS.Shapefile
        'Open a shapefile
        sf.Open("C:\CITIES.SHP", Me)
        'Add shapefile to map, saving layer handle
        hnd = Map1.AddLayer(sf, True)
        '*****************************************
        'Add Grid to Map
        Dim grid As MapWinGIS.Grid
        'Open a grid
        grid.Open("C:\GRID.ASC", MapWinGIS.GridDataType.UnknownDataType, True, MapWinGIS.GridFileType.UseExtension, Me)
        'create the grid coloring scheme
        Dim scheme As New MapWinGIS.GridColorScheme()
        scheme.NoDataColor = System.Convert.ToUInt32(RGB(0, 0, 0))
        scheme.UsePredefined(grid.Minimum, grid.Maximum, MapWinGIS.PredefinedColorScheme.SummerMountains)
        'convert the grid to an image
        Dim image As MapWinGIS.Image
        Dim util As New MapWinGIS.Utils()
        image = util.GridToImage(grid, scheme, Me)
        'add the image to the map
        Map1.AddLayer(image, True)
    End Sub
  

VB 6 Usage

Function AddLayer(Object As Object, Visible As Boolean) As Long

            Parameters

Object

The object (Image or Shapefile) to add to the map.
Visible Sets whether or not the layer is visible after being added to the map.

Return Value

Returns integer handle to layer added to the map.

Sample Code

    Private Sub AddLayerToMap()
        'Add Shapefile to Map
        Dim hnd As Long
        Dim success As Boolean
        Dim sf As Shapefile
        'Open a shapefile
        success = sf.Open("C:\CITIES.SHP", Me)
        'Add shapefile to map, saving layer handle
        hnd = Map1.AddLayer(sf, True)
        '*****************************************
        'Add Grid to Map
        Dim grid As MapWinGIS.grid
        'Open a grid
        success = grid.Open("C:\GRID.ASC", MapWinGIS.GridDataType.UnknownDataType, True, MapWinGIS.GridFileType.UseExtension, Me)
        'create the grid coloring scheme
        Dim scheme As New MapWinGIS.GridColorScheme
        scheme.NoDataColor = RGB(0, 0, 0)
        scheme.UsePredefined grid.Minimum, grid.Maximum, MapWinGIS.PredefinedColorScheme.SummerMountains
        'convert the grid to an image
        Dim image As MapWinGIS.image
        Dim util As New MapWinGIS.Utils
        image = util.GridToImage(grid, scheme, Me)
        'add the image to the map
        hnd = Map1.AddLayer image, True
    End Sub

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

This page has been accessed 7,260 times. This page was last modified on 26 September 2008, at 20:29.