Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Convert mouse position to langtitude-longitude on a map

Convert mouse position to langtitude-longitude on a map

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johnkokk
    wrote on last edited by
    #1

    OK, let's say i have this map loaded on a form http://upload.wikimedia.org/wikipedia/commons/9/92/Satellite_image_of_Greece.jpg[^]. Is there a way to convert the mouse position on that map as i move, to latitude and longitude ? If no, how such a thing can be done ? Thanks.

    S 1 Reply Last reply
    0
    • J Johnkokk

      OK, let's say i have this map loaded on a form http://upload.wikimedia.org/wikipedia/commons/9/92/Satellite_image_of_Greece.jpg[^]. Is there a way to convert the mouse position on that map as i move, to latitude and longitude ? If no, how such a thing can be done ? Thanks.

      S Offline
      S Offline
      Steven J Jowett
      wrote on last edited by
      #2

      If you know the coordinance of the top-left and the bottom-right, then it's down to basic maths to calculate the coordinance that the mouse is pointing to.

      Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

      D 1 Reply Last reply
      0
      • S Steven J Jowett

        If you know the coordinance of the top-left and the bottom-right, then it's down to basic maths to calculate the coordinance that the mouse is pointing to.

        Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

        D Offline
        D Offline
        David Skelly
        wrote on last edited by
        #3

        One thing to be aware of is that a map is a projection of a three dimensional curved surface onto a two dimensional plane, and there are different ways of handling that projection. So in order to convert the mouse position to a latitude/longitude on the map you need to know the projection in use for this particular map. In this case, it's not really a map, it's a satellite photograph. I have no idea how the maths works for mapping a 2D digital photograph back to the corresponding real-world position on the surface of a sphere. In fact the world is an oblate spheroid, I think, not a perfect sphere but you could probably make things easy by assuming a sphere and still be close enough for most practical purposes unless you're planning to write your own cruise missile guidance system.

        S 1 Reply Last reply
        0
        • D David Skelly

          One thing to be aware of is that a map is a projection of a three dimensional curved surface onto a two dimensional plane, and there are different ways of handling that projection. So in order to convert the mouse position to a latitude/longitude on the map you need to know the projection in use for this particular map. In this case, it's not really a map, it's a satellite photograph. I have no idea how the maths works for mapping a 2D digital photograph back to the corresponding real-world position on the surface of a sphere. In fact the world is an oblate spheroid, I think, not a perfect sphere but you could probably make things easy by assuming a sphere and still be close enough for most practical purposes unless you're planning to write your own cruise missile guidance system.

          S Offline
          S Offline
          Steven J Jowett
          wrote on last edited by
          #4

          David Skelly wrote:

          unless you're planning to write your own cruise missile guidance system.

          Well actually..... ;)

          Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups