MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Obtain LatLong with Address

This is a discussion on Obtain LatLong with Address within the MapPoint Web Service and Virtual Earth forums, part of the Map Forums category; Hi! I have a problem: I've a form in wich I put some address data: city, postcode, direction, etc. The ...


Go Back   MapPoint Forums > Map Forums > MapPoint Web Service and Virtual Earth

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



Click here to register

Reply

 

LinkBack (5) Thread Tools Display Modes
  5 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 04-08-2006
Junior Member
White Belt
 
Join Date: Feb 2006
Posts: 11
Obtain LatLong with Address

Hi!
I have a problem:
I've a form in wich I put some address data: city, postcode, direction, etc.
The question is: can i obtain the latlong of this place with an address object? And how do it? Are there any method or function for do it?
Many thanks!
__________________
Ivan
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 04-10-2006
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 899
Blog Entries: 10
You need Gilles Kohl's "CalcPos()" routine. Do a search on this website to find it (sorry don't have the URL handy).
This is in VB6 and takes a location object, and returns the longitude,latitude coordinate using some cunning geometry.

It is easily ported to other languages (I've ported it to C++ and FoxPro in the past), although you should keep the double precision maths.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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 04-10-2006
Junior Member
Yellow Belt
 
Join Date: Dec 2005
Posts: 22
Send a message via AIM to Mark - MSFT
MapPoint 2006

Also, the new version (due out this month) of MapPoint does have a Lat/Lon method which allows you do dump your lat lons programmatically.


Mark - MSFT
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 12-25-2006
AUR AUR is offline
Junior Member
White Belt
 
Join Date: Dec 2006
Posts: 11
Re: Obtain LatLong with Address

Hello Mark

I've a problem, i need to export all streets addresses+lat/lon into an external file ( this is the builtin mappoint dataset), so that later i can import in access database and show it on access forms and communicate with Map point.

Please can you help me.

regards
AUR
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 12-26-2006
Junior Member
Yellow Belt
 
Join Date: Sep 2002
Posts: 20
Re: Obtain LatLong with Address

Ivan

Here is some reference code to point you in the right direction. You will need to tweak it to get it to work. This should work for both MP2004 and 2006. For 2006 you can of course use the Lat/Lon method as Mark pointed out.


Public Function FindContactEX(ByVal sAddress As String, _
Optional ByVal ShowFindDialog As Boolean = True, _
Optional ByVal AddPushPin As Boolean = False) As Object

Dim objFindResults As MapPointCtl.FindResults
Dim objLoc As Object
Dim objPushPin As MapPointCtl.Pushpin
Dim lngI As Long
Dim strAddress As String
Dim arrAddress As Variant
Dim CountryObject As Object


Set FindContactEX = Nothing

MultipleMatches = 0
Set m_FindResults = Nothing
Set m_FindResults = New Collection

strAddress = sAddress

If Trim(strAddress) = "" Then
Exit Function
End If

'Output first result of find search
Set objFindResults = ctlMap.ActiveMap.FindResults(strAddress)

If objFindResults.Count = 0 Or objFindResults.ResultsQuality > 2 Then
If InStr(1, strAddress, ",") Then
arrAddress = Split(strAddress, ",")
If IsArrayDimensioned(arrAddress) Then
Set objFindResults = ctlMap.ActiveMap.FindResults(arrAddress(UBound(arr Address)))
If objFindResults.Count > 0 Then
Set CountryObject = objFindResults.Item(1)
Set objPushPin = ctlMap.ActiveMap.AddPushPin(CountryObject)
objPushPin.Symbol = cPP_CONTACTRED
CountryObject.GoTo
End If
End If
End If
Exit Function
ElseIf objFindResults.Count >= 1 And objFindResults.Count <= 3 Then
Set FindContactEX = objFindResults.Item(1)
If AddPushPin Then
Set objPushPin = ctlMap.ActiveMap.AddPushPin(FindContactEX, strAddress)
objPushPin.Symbol = cPP_CONTACTRED
FindContactEX.GoTo
End If
Else
MultipleMatches = objFindResults.Count
For lngI = 1 To objFindResults.Count
Set objLoc = objFindResults.Item(lngI)
If TypeOf objLoc Is MapPointCtl.Location Then
m_FindResults.Add objLoc
End If
Next lngI

If ShowFindDialog Then
Set FindContactEX = ctlMap.ActiveMap.ShowFindDialog(strAddress, geoFindDefault)
If Not FindContactEX Is Nothing Then
If TypeOf FindContactEX Is MapPointCtl.Location Then
Else
Set FindContactEX = m_NewSelection ' m_NewSelection will be set in ctlMap_SelectionChange event
End If
End If
End If
End If

End Function

Public Sub GetGeoCodes(ByVal sAddress As String, _
ByRef dblLat As Double, ByRef dblLon As Double, _
Optional ByVal ShowFindDialog As Boolean = True, _
Optional ByVal AddPushPin As Boolean = False)

Static locNorthPole As MapPointCtl.Location
Static locSantaCruz As MapPointCtl.Location ' Center of western hemisphere
Static dblHalfEarth As Double ' Half circumference of the earth (as a sphere)
Static dblQuarterEarth As Double ' Quarter circumference of the earth (as a sphere)
Static Pi As Double
Dim objMap As MapPointCtl.Map
Dim LocX As MapPointCtl.Location
Dim l As Double
Dim d As Double

dblLat = 0#
dblLon = 0#

If ctlMap.ActiveMap Is Nothing Then
Err.Raise vbError + 1000, "GetGeoCodes", "Map control does not have any active map."
Exit Sub
Else
Set objMap = ctlMap.ActiveMap
End If

Set LocX = FindContactEX(sAddress, ShowFindDialog, AddPushPin)
If LocX Is Nothing Then
If (UseZipcodeMatching = True) And (ZipCode <> "") Then
m_GeocodeLevel = GCNone
Set LocX = FindContactEX(ZipCode, ShowFindDialog, AddPushPin)
If LocX Is Nothing Then
Exit Sub
Else
If UIMode = False Then
m_GeocodeLevel = GCPostalCode
Else
m_FindResults.Add LocX
Exit Sub
End If
End If
Else
Exit Sub
End If
Else
m_GeocodeLevel = GCStreet
End If

' Check if initialization already done
If locNorthPole Is Nothing Then
Set locNorthPole = objMap.GetLocation(90, 0)
Set locSantaCruz = objMap.GetLocation(0, -90)

' Compute distance between north and south poles == half earth circumference
dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0))

' Quarter of that is the max distance a point may be away from locSantaCruz and still be in western hemisphere
dblQuarterEarth = dblHalfEarth / 2
Pi = 3.14159265358979
End If

' Compute latitude from distance to north pole
dblLat = 90 - 180 * objMap.Distance(locNorthPole, LocX) / dblHalfEarth

' Compute great circle distance to locX from point on Greenwich meridian and computed Latitude
d = objMap.Distance(objMap.GetLocation(dblLat, 0), LocX)

' convert latitude to radian
l = (dblLat / 180) * Pi

' Compute Longitude from great circle distance
dblLon = 180 * Arccos((Cos((d * 2 * Pi) / (2 * dblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / Pi

' Correct longitude sign if located in western hemisphere
If objMap.Distance(locSantaCruz, LocX) < dblQuarterEarth Then dblLon = -dblLon

RaiseEvent GotLatLong(dblLat, dblLon)

If AddPushPin Then
Set LocX = objMap.GetLocation(dblLat, dblLon)
If Not (LocX Is Nothing) Then
objMap.AddPushPin LocX, sAddress
LocX.GoTo
End If
End If

End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 05-24-2007
Junior Member
White Belt
 
Join Date: May 2007
Posts: 1
Re: MapPoint 2006

Quote:
Originally Posted by Mark - MSFT View Post
Also, the new version (due out this month) of MapPoint does have a Lat/Lon method which allows you do dump your lat lons programmatically.


Mark - MSFT
I am aware of the CalcPos function - although I don't know where to actually paste the code. But I have a trial version of MapPoint 2006 and am not seeing the Lat/Long method mentioned above. When I export to Excel, lat/long is not included and there are no options to customize which fields go. Can someone point me in the right direction?
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
address, latlong, obtain


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/obtain-latlong-address-4897.html

Posted By For Type Date
Aide pour mappoint europe 2006] - PC SOFT - Forum consacré à WinDev This thread Refback 09-25-2008 06:23 AM
PC SOFT - Forums dveloppeurs This thread Refback 04-28-2008 05:05 AM
PC SOFT - Forums dveloppeurs This thread Refback 04-24-2008 05:48 AM
PC SOFT - Forums dveloppeurs This thread Refback 04-22-2008 12:16 PM
PC SOFT - Forums dveloppeurs This thread Refback 04-22-2008 10:54 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 On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
LatLong to Address ?? xaxas MapPoint 2006/2009 Discussion 5 10-19-2008 10:16 PM
Getting informations about geographic coordinates (LatLong) badzio MapPoint Web Service and Virtual Earth 4 08-02-2005 09:34 AM
Obtain X, Y from Lat, Long mikica1972 MapPoint 2006/2009 Discussion 1 10-27-2003 08:47 AM
How to obtain ZIP code from lat-long? BC MapPoint 2006/2009 Discussion 1 04-29-2003 06:49 AM
Is there a way I can obtain a copy of the EULA for.... Anonymous MapPoint 2006/2009 Discussion 1 07-30-2001 08:57 AM


All times are GMT -5. The time now is 10:50 AM.


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