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 ProjToPixel

From MapWindow GIS

Jump to: navigation, search

ProjToPixel

Converts projected map coordinates into screen pixel units.


VB.NET Usage

Sub ProjToPixel(projX As Double, projY As Double, ByRef pixelX As Double, ByRef pixelY As Double)

            Parameters

projX

The projected x map coordinate to be converted into the x pixel coordinate.
projY The projected y map coordinate to be converted into the y pixel coordinate.
pixelX The pixel x coordinate is returned through this reference parameter.
pixelY The pixel y coordinate is returned through this reference parameter.

Sample Code

    Private Sub DrawCenterCircle()
        Dim draw_hndl As Integer
        Dim xProjCenter As Double, yProjCenter As Double
        Dim xScreenCenter As Double, yScreenCenter As Double
        Dim extents As MapWinGIS.Extents
        'Get the extents of Map1
        extents = Map1.Extents
        'Calculate the center x coordinate of the map
        xProjCenter = extents.xMin + ((extents.xMax - extents.xMin) / 2)
        'Calculate the center y coordinate of the map
        yProjCenter = extents.yMin + ((extents.yMax - extents.yMin) / 2)
        'Convert from the projected map coordinates of the center of the map to pixel coordinates
        Map1.ProjToPixel(xProjCenter, yProjCenter, xScreenCenter, yScreenCenter)
        'Create a new drawing layer
        draw_hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList)
        'Draw a circle centered around the center of the map's view
        Map1.DrawCircle(xScreenCenter, yScreenCenter, 50, System.Convert.ToUInt32(RGB(255, 0, 0)), False)
    End Sub
  

VB 6 Usage

Sub ProjToPixel(projX As Double, projY As Double, ByRef pixelX As Double, ByRef pixelY As Double)
            Parameters

projX

The projected x map coordinate to be converted into the x pixel coordinate.
projY The projected y map coordinate to be converted into the y pixel coordinate.
pixelX The pixel x coordinate is returned through this reference parameter.
pixelY The pixel y coordinate is returned through this reference parameter.

Sample Code

    Private Sub DrawCenterCircle()
        Dim draw_hndl As Long
        Dim xProjCenter As Double, yProjCenter As Double
        Dim xScreenCenter As Double, yScreenCenter As Double
        Dim extents As MapWinGIS.extents
        'Get the extents of Map1
        Set extents = Map1.extents
        'Calculate the center x coordinate of the map
        xProjCenter = extents.xMin + ((extents.xMax - extents.xMin) / 2)
        'Calculate the center y coordinate of the map
        yProjCenter = extents.yMin + ((extents.yMax - extents.yMin) / 2)
        'Convert from the projected map coordinates of the center of the map to pixel coordinates
        Map1.ProjToPixel xProjCenter, yProjCenter, xScreenCenter, yScreenCenter
        'Create a new drawing layer
        draw_hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList)
        'Draw a circle centered around the center of the map's view
        Map1.DrawCircle xScreenCenter, yScreenCenter, 50, RGB(255, 0, 0), False
    End Sub

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