World map embedded in userform.

P

Paul

Hi,

Is it possible to embed a map into a userform? What I'm trying to accomplish
is that a map, lets say europe, is displayed and everytime when the user
clicks on the map the lat/long coordinates of the pointer are transferred to
an excel sheet.

Any ideas?

Cheers,

Paul
 
P

Peter T

Indeed you can embed a an image into the entire form or probably better into
an Image control. Click the "Picture" property and browse to your image.

Set AutoSize to true and experiment with PictureSizeMode. Maybe later you
can change Autosize to false.

In the form code (assuming the image control is named Image1)

Private Sub Image1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Range("A1").Value = X
Range("B1").Value = Y
End Sub

Private Sub Image1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Me.Caption = X & " " & Y
End Sub


You will of course need to calibrate X & Y to relate to your map
coordinates. Assuming the Grid is linear in both axes (don't assume it is),
maybe something like this

With Image1
east = (.Width / X) x (maxEast - minEast)
north = (.Height/ Y) x (maxNorth - minNorth)
End With

where max/min East/north are grid coord's at left, right top & bottom of the
map
Regards,
Peter T
 
P

Paul

Peter,

Thanks for the reply that helps a lot just a couple of things I can't figure
out and that has mostly to do with the co-ordinates;

I've got a map, from google earth, and I'm using co-ordinates in degrees,
minutes (so 51 08N21 47E, etc etc), and I can't get the right co-ordinates to
be displayed on my map.

If I reach the top of my map one of the values states zero, but it should
state 51 degrees 08 minutes North instead of zero.

Could you help me?

Cheers,

Paul
 
P

Paul

Peter,

Thanks for the reply that helps a lot just a couple of things I can't figure
out and that has mostly to do with the co-ordinates;

I've got a map, from google earth, and I'm using co-ordinates in degrees,
minutes (so 51 08N21 47E, etc etc), and I can't get the right co-ordinates to
be displayed on my map.

If I reach the top of my map one of the values states zero, but it should
state 51 degrees 08 minutes North instead of zero.

Could you help me?

Cheers,

Paul
 
P

Peter T

What are the grid coordinates at top left and bottom right corners. Does the
meridian intersect, Europe so I guess it does, at what distance from the
left, as a fraction of the total width (ie a decimal between 0 & 1).

What is width & height of the image (get from properties).

Double check that coord's along the centre and vertical lines are as you
would expect (ie the scales linear).

Regards,
Peter T
 
P

Paul

Peter,

Some has gone wrong in my last reply... I had some internet problems last
night so that might be the reason...

Indeed europe intersects, but I'm creating country maps so it doesn't affect
me that much.

the Top left coordinates from my first picture are 53 degrees 44 minutes
North / 01 degrees 38 minutes East.

Bottom right are 52 degrees 09 minutes N / 06 degrees 10 minutes East.

The heigth of my picture = 528 and the width = 966.

Can you help me out?

Cheers,

Paul.
 
P

Peter T

From the info you gave it looks like your map grid is not simply rectangular
(as a street map typically is). The grid may be skewed in any one of a
number of ways. Eg longitudes not vertical and/or not parallel. Or maybe the
map is merely squashed in one direction. For some purposes it's inconvenient
that the world is spherical rather than flat !

Tp-lt 53:4n~01:38e = 53+(44/60) ~ -(1+(38/60)) = 53.73 ~ -1.633
Bt-rt 52:09n~06:10e = 52+(9/60) ~ -(6+(10/60)) = 52.15 ~ -6.167

I've omitted the calc but the horizontal/vertical ratio of these coord's is
2.86 vs the wd/ht of your image of 1.85 (966 / 528)

Will need coord's of the other corners and ideally at centre and perhaps at
the mid points of the edges.

Although it could be tedious it should be relatively straightforward to
interpolate mouse X:Y to the grid.

Regards,
Peter T
 
P

Paul

Peter,

Hereby the requested co-ordinates might be different than the last, I had to
reset my google earth;

Top left: 53 degrees 32 min North / 01 degress 15 min East
Top right: 53 degrees 46 min North / 11 degrees 22 min East
Bottom right: 50 degrees 32 min North / 10 degrees 58 min East
Bottom left: 50 degrees 34 min North / 01 degrees 34 min East
Center: 52 degrees 13 min N / 06 degrees 25 min East
Mid top: 53 degrees 52 min North / 06 degrees 25 min East
Mid bottom: 50 degrees 40 min North / 06 degrees 25 min East
Mid left: 52 degrees 13 min North / 01 Degrees 26 min East
Mid right: 52 degrees 13 min North / 11 degrees 09 min East

In your original message there where these two lines;
Tp-lt 53:4n~01:38e = 53+(44/60) ~ -(1+(38/60)) = 53.73 ~ -1.633
Bt-rt 52:09n~06:10e = 52+(9/60) ~ -(6+(10/60)) = 52.15 ~ -6.167

In wich event do I put these? Do i need to put this somewhere?

Peter do you think that it's possible to, after I've clicked the map and the
coordinates are put into a sheet, a marker of some kind shows on the map on
the place I just clicked?
And if it is, I also would like a button to press if I want to remove these
markers.

Thanks in advance,

Cheers,

Paul
 
P

Peter T

Hi Paul,
In wich event do I put these? Do i need to put this somewhere?

Those are simply edited "workings" to show how to convert grid coordinates
to decimals, and to get a quick idea if the grid is rectangular (for want of
a better description) which it did not appear to be. Were you able to
follow. FWIW I put the calc's in cell formulas. For your purposes they could
go in cells or calculated in VBA, it doesn't really matter.

I haven't yet looked in detail at your additional ref's. Have you, I mean in
terms of scaling to your image. What steps have you done so far towards
interpolating mouse X:Y to a grid ref. Is the grid "rectangular" or skewed
as I suspect.

Regards,
Peter T
 
P

Peter T

Hi Paul,
In wich event do I put these? Do i need to put this somewhere?

Those are simply edited "workings" to show how to convert grid coordinates
to decimals, and to get a quick idea if the grid is rectangular (for want of
a better description) which it did not appear to be. Were you able to
follow. FWIW I put the calc's in cell formulas. For your purposes they could
go in cells or calculated in VBA, it doesn't really matter.

I haven't yet looked in detail at your additional ref's. Have you, I mean in
terms of scaling to your image. What steps have you done so far towards
interpolating mouse X:Y to a grid ref. Is the grid "rectangular" or skewed
as I suspect.

Regards,
Peter T
 
P

Paul

Peter,

The grid is not rectangular, the map I'm currently working on is a complete
overview of the Netherlands, and therefore the grid is following the curves
of the earth.

If you've got suggestions for maps, other than google earth maps, that are
easier to handle, I would like to hear them..

Cheers,

Paul
 
P

Peter T

Even if the grid is not rectangular, with sufficient known coordinates to
hand (as indeed you have) it should be possible to devise your own
interpolation algorithm to relate mouse X:Y to the grid.

Regards,
Peter T
 
P

Paul

Peter,

Could you point me in the right direction, I have no clue where to begin...

Cheers,

Paul
 
P

Peter T

Why not plot those 9 refs on paper (like on a graph). Convert the minutes to
decimals of a degree first (as in demonstrated earlier). Dig out your old
maths & trig school books.

Just at a visual glance of those ref's I rather suspect they are not
accurate, even though no doubt the grid is "skewed".

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top