PDA

View Full Version : Identifying Selection with Mouse



MapPointJim
08-20-2002, 12:50 PM
working in VB with a Mappoint object.

I'm trying to select a starting point on a map (a lat/long position) using my mouse pointer. It looks like I can either
click a location on a map (like a city) or draw a rectangle. Either way I need to identify the lat/long of either the selected city or upper left corner of my drawn retangle.

I have some code I downloaded off this site to identify the lat log if given zipcode for the input. My question is this: Can I return a zipcode from either of the above two selection methods? Or is there a better way to do this.

John Meyer
08-20-2002, 02:52 PM
This code sample will: If you click your mouse on the map, if it is a location type it will give you a message box with the Lat/Lon.

Here is an article you need to check out: A More Compact Method for Obtaining Lat/Long. Author: Gilles Kohl

http://www.mp2kmag.com/articles.asp?ArticleID=13


'Put Gilles code in a bas module for the CalcPos function call.

'Put this in the general declatations section
Public thelat As Double
Public thelon As Double


'I'm using a Mappoint ActiveX Control named MappointControl1 on my form for this example


Private Sub MappointControl1_SelectionChange(ByVal pNewSelection As Object, ByVal pOldSelection As Object)
On Error GoTo error:
Dim objmap As MapPointCtl.Map
Dim objLoc As MapPointCtl.Location
Set objmap = MappointControl1.ActiveMap
If TypeOf objmap.Selection Is Location Then
Set objLoc = objmap.Selection

CalcPos objmap, objLoc, thelat, thelon
MsgBox thelat & " , " & thelon
End If

Exit Sub
error:
End Sub

MapPointJim
08-20-2002, 03:43 PM
works great!

though now I get a server busy box. It asks to "switch to" or "retry". To get out of it I must use task manager.

John Meyer
08-20-2002, 04:39 PM
I think if you do something with the lat/lon other than bring it up in a message box you will not get that error. The message box is waiting for you to click "OK" keeping that SelectionChange event open gives that error.