MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Find latitude and longitude of map corners with VBA

This is a discussion on Find latitude and longitude of map corners with VBA within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hi, I use the following code to place pushpins on a map and zoom in the area. Do Until oWorksheet2.Cells(i, ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 05-18-2007
Junior Member
White Belt
 
Join Date: May 2007
Location: Montreal
Posts: 11
Find latitude and longitude of map corners with VBA

Hi,

I use the following code to place pushpins on a map and zoom in the area.

Do Until oWorksheet2.Cells(i, 1) = 0
sStation = oWorksheet2.Cells(i, 1)

Set oStation = oMap.FindResults(sStation).Item(1)
oMap.AddPushpin oStation
i = i + 1
Loop
oMap.DataSets.ZoomTo

I also use the code http://www.mp2kmag.com/a13--kohl.extract.lat.lon.mappoint.html to find latitude and longitude of each pushpin. However, I also need to know what is the latitude and longitude of each corner of my map. How can I do that with VBA code.

Thanks for help

A.Ouellet

p.s: I am a french Canadian. I am sorry for all possible English mistakes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 05-18-2007
Senior Member
Blue Belt
 
Join Date: Dec 2002
Posts: 251
Re: Find latitude and longitude of map corners with VBA

Well ... I might do it like this:

Type LATLONGPOINT
x As Double
y As Double
End Type

Dim CNW As LATLONGPOINT
Dim CNE As LATLONGPOINT
Dim CSW As LATLONGPOINT
Dim CSE As LATLONGPOINT

Dim NWC As MapPointCtl.Location
Dim NEC As MapPointCtl.Location
Dim SWC As MapPointCtl.Location
Dim SEC As MapPointCtl.Location

Dim dblLatNWC As Double
Dim dblLongNWC As Double

Dim dblLatSWC As Double
Dim dblLongSWC As Double

Dim dblLatNEC As Double
Dim dblLongNEC As Double

Dim dblLatSEC As Double
Dim dblLongSEC As Double

Public Function OutputDimensions()

'Mattys Consulting

Dim dblWidthTop As Double, dblWidthBottom As Double
Dim dblHeightWest As Double, dblHeightEast As Double

CNW.x = 0: CNW.y = 0
CSW.x = 0: CSW.y = oMap.Height
CNE.x = oMap.Width: CNE.y = 0
CSE.x = oMap.Width: CSE.y = oMap.Height

On Error Resume Next

Set NWC = oMap.XYToLocation(CNW.x, CNW.y)
Set SWC = oMap.XYToLocation(CSW.x, CSW.y)
Set NEC = oMap.XYToLocation(CNE.x, CNE.y)
Set SEC = oMap.XYToLocation(CSE.x, CSE.y)

If (dblLatNWC = 0 And dblLongNWC = 0) = False Then

'CalcPos courtesy of Gilles Kohl
CalcPos oMap, NWC, dblLatNWC, dblLongNWC
CalcPos oMap, SWC, dblLatSWC, dblLongSWC
CalcPos oMap, NEC, dblLatNEC, dblLongNEC
CalcPos oMap, SEC, dblLatSEC, dblLongSEC

'Add pushpins if desired
Set NWC = oMap.GetLocation(dblLatNWC, dblLongNWC)
Set SWC = oMap.GetLocation(dblLatSWC, dblLongNWC)
Set NEC = oMap.GetLocation(dblLatNWC, dblLongNEC)
Set SEC = oMap.GetLocation(dblLatSWC, dblLongNEC)

dblWidthTop = oMap.Distance(NWC, NEC)
dblWidthBottom = oMap.Distance(SWC, SEC)

dblHeightWest = oMap.Distance(NWC, SWC)
dblHeightEast = oMap.Distance(NEC, SEC)

End If

End Function

If you have any questions, just ask.

Mike Mattys
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 05-22-2007
Junior Member
White Belt
 
Join Date: May 2007
Location: Montreal
Posts: 11
Re: Find latitude and longitude of map corners with VBA

Thank you Mike. Very helpful

A.Ouellet
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
corners, find, latitude, longitude, map, vba


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/find-latitude-longitude-map-corners-vba-5886.html

Posted By For Type Date
Area in Mappoint - microsoft.public.mappoint | Google Gruppi This thread Refback 01-16-2008 11:38 AM
MapPoint Articles - MP2K Magazine This thread Refback 05-29-2007 09:51 AM
Determing Whether A Point Is Located Inside Polygon - MapPoint Articles - MP2K Magazine This thread Refback 05-19-2007 08:07 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
find Location Name through Longitude Latitude Anonymous MapPoint 2006/2009 Discussion 3 07-24-2008 01:58 AM
Using longitude and latitude to find adress Edward_Carnby MapPoint 2006/2009 Discussion 4 07-22-2008 09:12 AM
How to get latitude and longitude ma2005pp MapPoint 2006/2009 Discussion 3 09-28-2005 02:57 AM
Latitude and Longitude virgilar MapPoint 2006/2009 Discussion 1 03-21-2005 02:01 PM
NMEA latitude/longitude and mappoint latitude/longitude muurman MapPoint 2006/2009 Discussion 3 11-22-2003 05:42 AM


All times are GMT -5. The time now is 01:02 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55