Hi all,
I have seen a lot of code on this but nothing that I really understood.
I have a form with a picturebox. In this picturebox I have an image that
displays a map.
What I want to do is have a textbox on the bottom of the screen that
displays the cursor position when I move the mouse over the screen.
I need to be able to translate these X and Y to latitude and longitude.
I know it has to do with scalemode and getcursorposition etc...
Please some sample code
Regards
Marco
The Netherlands
Frank Adam - 30 Jan 2004 23:56 GMT
>Hi all,
>
[quoted text clipped - 8 lines]
>
>Please some sample code
Assuming that your image is in Image1..
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'this will likely be twips, unless you've changed the scalemode.
Me.Caption = X & ":" & Y & " in inches: "
' here is how to convert it to more human friendly stuff.
' Hit F1 for the other scalex and scaley contants.
Me.Caption = Me.Caption & ScaleX(X, ScaleMode, vbInches) & ":"
Me.Caption = Me.Caption & ScaleY(Y, ScaleMode, vbInches)
End Sub

Signature
Regards, Frank
BeastFish - 31 Jan 2004 00:02 GMT
Look at the X and Y coordinates of the MouseMove, MouseDown, MouseUp events
of the picturebox. They'll give you the X and Y positions of the mouse
pointer in whichever scale of the picturebox's ScaleMode. Then you'd have
to devise a formula to convert these values into logitude/latitude depending
on the image.
> Hi all,
>
[quoted text clipped - 12 lines]
> Marco
> The Netherlands
Greg Siemon - 31 Jan 2004 00:20 GMT
LonLeft = -180
LonRight = 180
LatTop = 90
LatBottom = -90
picMap.Scale (LonLeft, LatTop)-(LonRight, LatBottom)
> Hi all,
>
[quoted text clipped - 12 lines]
> Marco
> The Netherlands
Greg Siemon - 31 Jan 2004 00:23 GMT
BTW
Sign of X and Y will tell you if your East/West Lon and North/South Lat
> LonLeft = -180
>
[quoted text clipped - 22 lines]
> > Marco
> > The Netherlands
Krechting - 31 Jan 2004 11:53 GMT
Greg,
tnx for this but could you be more specific on how to use this.
I put this code in the Form load event but how does it work with
scale of the map. How does VB know where he is on the world in relation
to lat/long.
Do I have to set the scaleheight, scaleleft, scalebottom etc?
Regards,
Marco
> BTW
>
[quoted text clipped - 26 lines]
> > > Marco
> > > The Netherlands
Greg Siemon - 31 Jan 2004 15:01 GMT
<<Do I have to set the scaleheight, scaleleft, scalebottom etc?>>
VB does it all for you.
By changing the Scale you have changed the ScaleMode to User.
ScaleHeight becomes LatTop-LatBottom or 180, ScaleWidth becomes
LonRight-LonLeft or 360
Go to:
http://members.cox.net/avnav/
and look at my system. You can download and try. It's free. Look at the
map part of the system. If you are an airplane pilot it will be more fun.
Greg
> Greg,
>
[quoted text clipped - 39 lines]
> > > > Marco
> > > > The Netherlands