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 PixelToProj

From MapWindow GIS

Jump to: navigation, search

PixelToProj

Converts pixel coordinates to projected map coordinates.


VB.NET Usage

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

            Parameters

pixelX

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

Sample Code

    Private Sub Map1_MouseUpEvent(ByVal sender As System.Object, ByVal e As AxMapWinGIS._DMapEvents_MouseUpEvent) Handles Map1.MouseUpEvent
        'This will draw a point where you click on the map if you have a 
        'spatially referenced shapefile or grid displayed on the map
        Dim x As Double, y As Double
        'Convert pixel coordinates of mouse up event e.x and e.y to projected coordinates returned by x and y
        Map1.PixelToProj(e.x, e.y, x, y)
        'Create a new drawing layer in map1
        Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList)
        'Draw a red point where the mouse up event occured in map1
        Map1.DrawPoint(x, y, 5, System.Convert.ToUInt32(RGB(255, 0, 0)))
    End Sub
  

'VB 6 Usage

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

pixelX

The x pixel coordinate.
pixelY The y pixel coordinate.
projX The projected x coordinate is returned through this reference parameter.
projY The projected y coordinate is returned through this reference parameter.

Sample Code

    Private Sub Map1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Long, ByVal Y As Long)
        'This will draw a point where you click on the map if you have a
        'spatially referenced shapefile or grid displayed on the map
        Dim px As Double, py As Double
        'Convert pixel coordinates of mouse down event e.x and e.y to projected coordinates returned by x and y
        Map1.PixelToProj X, Y, px, py
        'Create a new drawing layer in map1
        Map1.NewDrawing (dlSpatiallyReferencedList)
        'Draw a red point where the mouse down event occured in map1
        Map1.DrawPoint px, py, 5, RGB(255, 0, 0)
    End Sub

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