MapWindow Home
Search MapWindow.org


  • Home
    • Download
    • Why MW
    • FAQ
    • Contact
  • Products
    • MapWindow
    • ActiveX
    • Plug-ins
  • Software Dev
    • Sample Code
    • Scripts
    • Source
    • Bugs
    • Support
    • Languages
  • Site Tools
    • Forums
    • Tutorials
    • Mailing Lists
    • Team
    • Site Stats
    • Links
  • Get Stuff
    • Buy a CD
    • Buy a T-Shirt
    • MW Book
    • ActiveX Book
    • Donate
    • Buy Support
  • Documentation
    • MWGIS App. User Guide
    • GISTools User Guide
    • MW Plug-ins Dev. Guide
    • MWGIS ActiveX Dev. Guide
    • MWGeoProc Dev. Guide

MapWinGIS:AxMap AddLayer

From MapWindow GIS

Jump to: navigation, search

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://www.mapwindow.org/wiki/index.php/MapWinGIS:AxMap_AddLayer"
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in / create account
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link

Geospatial Software Lab

Copyright © 2008 - MapWindow Open Source Team
( last updated: November 12 2008.)
Home | Donate | Download | MapWindow GIS Desktop | MapWinGIS.ocx | Plug-ins | Contact | Lists | Bugs | Sample Code | Documentation
Code Repository | Open Source License | Discussion Forum | Wiki | Join the Team | Site Statistics | Links