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 NewDrawing

From MapWindow GIS

Jump to: navigation, search

NewDrawing

Creates a new drawing layer on the map returning its handle.
See also tkDrawReferenceList


VB.NET Usage

Function NewDrawing(Projection As MapWinGIS.tkDrawReferenceList) As Integer

            Parameters

Projection

Sets the coordinate system to use for the new drawing layer to be created. (ScreenReferenced uses pixels in screen coordinates. SpatiallyReferenced uses projected map units.)
ReturnValue The handle for the new drawing layer in the map.

Sample Code

    Private Sub NewDrawing(ByVal DrawSpatiallyReferenced As Boolean)
        Dim hndl As Integer
        Dim xProjCenter As Double, yProjCenter As Double
        Dim xScreenCenter As Double, yScreenCenter As Double
        Dim extents As MapWinGIS.Extents
        'Get map extents
        extents = Map1.Extents
        'find the center of the view
        xProjCenter = extents.xMin + ((extents.xMax - extents.xMin) / 2)
        yProjCenter = extents.yMin + ((extents.yMax - extents.yMin) / 2)
        'create a new drawing surface
        If (DrawSpatiallyReferenced) Then
            'Use spatially referenced coordinates for new drawing layer and save handle
            hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)
            'Draw circle on last created drawing surface
            Map1.DrawCircle(xProjCenter, yProjCenter, 100, System.Convert.ToUInt32(RGB(255, 0, 0)), True)
        Else
            'Get center of the screen in pixel units from projected map coordinates
            Map1.ProjToPixel(xProjCenter, yProjCenter, xScreenCenter, yScreenCenter)
            'Use screen referenced coordinates for new drawing layer and save handle
            hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList)
            'Draw circle on last created drawing surface
            Map1.DrawCircle(xScreenCenter, yScreenCenter, 100, System.Convert.ToUInt32(RGB(255, 0, 0)), True)
        End If
    End Sub
  

VB 6 Usage

Function NewDrawing(Projection As tkDrawReferenceList) As Long
            Parameters

Projection

Sets the coordinate system to use for the new drawing layer to be created. (ScreenReferenced uses pixels in screen coordinates. SpatiallyReferenced uses projected map units.)
ReturnValue Handle for the new drawing layer in the map.

Sample Code

    Private Sub NewDrawing(ByVal DrawSpatiallyReferenced As Boolean)
        Dim hndl As Long
        Dim col As OLE_COLOR
        Dim xProjCenter As Double, yProjCenter As Double
        Dim xScreenCenter As Double, yScreenCenter As Double
        Dim extents As MapWinGIS.extents
        'Get map extents
        Set extents = Map1.extents
        'Get red color for drawing
        col = RGB(255, 0, 0)
        'find the center of the view
        xProjCenter = extents.xMin + ((extents.xMax - extents.xMin) / 2)
        yProjCenter = extents.yMin + ((extents.yMax - extents.yMin) / 2)
        radius = 100
        'create a new drawing surface
        If (DrawSpatiallyReferenced) Then
            'Use spatially referenced coordinates for new drawing layer and save handle
            hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)
            'Draw circle on last created drawing surface with a radius of 100
            Map1.DrawCircle xProjCenter, yProjCenter, 100, col, True
        Else
            'Get center of the screen in pixel units from projected map coordinates
            Map1.ProjToPixel xProjCenter, yProjCenter, xScreenCenter, yScreenCenter
            'Use screen referenced coordinates for new drawing layer and save handle
            hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList)
            'Draw circle on last created drawing surface
            Map1.DrawCircle xScreenCenter, yScreenCenter, 100, RGB(255, 0, 0), True
        End If
    End Sub

Retrieved from "http://www.mapwindow.org/wiki/index.php/MapWinGIS:AxMap_NewDrawing"
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