View Full Version : Using Msdn's Find Example
planethax
02-08-2011, 01:42 PM
So I download the Find example from Msdn.
I keep trying to find my address and address's near me but all results end in in the US and I am in Canada, is there something missing?
The MsgBox comes up with the address I write in
eg
7634 Woodbine Avenue Ontario l3r 2n2 Canada
But puts a push pin on a Woodbine in the USA?
And At the moment I just can not relocate where I downloaded the example, but I am still looking.
Eric Frost
02-08-2011, 01:56 PM
Maybe this? MapPoint Find Sample (http://msdn.microsoft.com/en-us/library/ms980051.aspx)
planethax
02-08-2011, 02:00 PM
Ahhhh, YES!!!! that is it!
Now if I search for
7634 Woodbine Avenue Ontario l3r 2n2 Canada
It brings me to a Woodbine in Fort Wayne Indiana ?
Eric Frost
02-08-2011, 02:05 PM
Can you post a screenshot of what the application looks like?
Eric
planethax
02-08-2011, 02:12 PM
If I pick the first Found Item it is in Indiana, pick the Second and it is in Alabama
http://i284.photobucket.com/albums/ll23/Dslrchat/find1.jpg
.
http://i284.photobucket.com/albums/ll23/Dslrchat/find2.jpg
I have done nothing to the Code, just downloaded it and tested it?
http://www.microsoft.com/downloads/details.aspx?familyid=7b5a7b28-8f05-4f73-ad51-e8ccccf9ec71&displaylang=en
Eric Frost
02-08-2011, 02:31 PM
I'm not totally sure, but I think maybe this line --
Set objLoc = objMap.FindResults(ListFindAddressResults.Text)(1)
should use FindAddressResults instead of FindResults ??
Try it and let us know if it helps.
Thanks,
Eric
Private Sub ListFindAddressResults_Click()
Dim objMap As MapPointCtl.Map
Dim objLoc As MapPointCtl.Location
Dim objPushPin As MapPointCtl.Pushpin
Set objMap = Form1.MappointControl1.ActiveMap
Set objLoc = objMap.FindResults(ListFindAddressResults.Text)(1)
objLoc.GoTo
If CheckPushpin.Value = 1 Then
strLocationText = ListFindAddressResults.Text
MsgBox strLocationText
'// Create a new pushpin.
Set objPushPin = objMap.AddPushpin(objLoc, strLocationText)
'// Display the balloon.
objPushPin.BalloonState = geoDisplayBalloon
'// Change pushpin symbol to one of the standard symbols.
'// 26 is a yellow circle.
objPushPin.Symbol = 26
objPushPin.Highlight = True
objPushPin.Note = "This is the address you selected!"
End If
End Sub
Eric Frost
02-08-2011, 02:33 PM
See the help file for more information on FindAddressResults, it takes several parameters
//Output first result of find search
objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", "", "WA", "", MapPoint.GeoCountry.geoCountryUnitedStates);
planethax
02-08-2011, 03:19 PM
See the help file for more information on FindAddressResults, it takes several parameters
//Output first result of find search
objFindResults = objApp.ActiveMap.FindAddressResults("One Microsoft Way", "Redmond", "", "WA", "", MapPoint.GeoCountry.geoCountryUnitedStates);
That doesnt seem to find anything at all,
I did a Debug.print, the exact results are
Debug.Print strAddressText
7634 woodbine avenue, markham, ontario, l3r2n2, Canada
I wonder if it is because the PostalCode is after the province?
planethax
02-08-2011, 03:33 PM
Hmmm
I did add
ComboState.AddItem "ON-Ontario"
and it did seem to find my postal code before erroring.
I will keep messing with it.
planethax
02-08-2011, 04:05 PM
And if I just put the Postal Code I get type mismatch
Set objLoc = objMap.FindResults(ListFindAddressResults.Text)(1)
Frustrating when even Microsofts code doesn't work :(
planethax
02-08-2011, 04:25 PM
Oh, just to add
If I use find in the MP object or I click Ctrl F in the project and search I can find my correct address. :(
planethax
02-09-2011, 10:48 AM
I am just plain frustrated now lol.
Might have to take a break from it :(
Eric Frost
02-09-2011, 10:56 AM
I think they just didn't test it for Canada..
FindAddressResults takes several parameters, so you would want to do something like this --
Set objLoc = objMap.FindAddressResults(ComboAddress.Text, ComboCity.Text, "", ComboState.Text, ComboZIPCode.Text, MapPoint.GeoCountry.geoCountryCanada)(1)
Obviously I didn't test it, but hopefully this helps you get it closer to working!
Eric
planethax
02-10-2011, 12:19 PM
Gone over this for days, I can not seem to figure out where the findstring is made?
If I can find that I think if I add
GeoCountry.geoCountryCanada
it may work.
planethax
02-10-2011, 01:08 PM
When searching for just postal code, the string is actuall
"L3R 2N2 (postal code), Canada"
maybe (postal code) causing the issues?
Eric Frost
02-10-2011, 01:24 PM
Did you try using this line instead of FindResults?
Set objLoc = objMap.FindAddressResults(ComboAddress.Text, ComboCity.Text, "", ComboState.Text, ComboZIPCode.Text, MapPoint.GeoCountry.geoCountryCanada)(1)
planethax
02-10-2011, 01:36 PM
Finally,
In the find query this worked!!!
Now I will add the provinces and make the Country actually selectable from USA and Canada.
Set objFindResults = objMap.FindAddressResults(ComboAddress.Text, ComboCity.Text, "", ComboState.Text, ComboZIPCode.Text, geoCountryCanada)
Thank you.
planethax
02-12-2011, 02:49 PM
So everything works fine in the MSDN Example.
Now when I try to port to my Project, I get a Runtime error when trying to set a PushPin
Private Sub ListFindAddressResults_Click()
Dim objMap As MapPointCtl.map
Dim objLoc As MapPointCtl.Location
Dim objPushPin As MapPointCtl.Pushpin
Set objMap = frmMain.MappointControl1.ActiveMap
Set objLoc = objMap.FindResults(ListFindAddressResults.Text)(1)
objLoc.GoTo
If CheckPushpin.Value = 1 Then
strLocationText = ListFindAddressResults.Text
' MsgBox strLocationText
'// Create a new pushpin.
Set objPushPin = objMap.AddPushpin(objLoc, strLocationText)
'// Display the balloon.
objPushPin.BalloonState = geoDisplayBalloon
'// Change pushpin symbol to one of the standard symbols.
'// 26 is a yellow circle.
objPushPin.Symbol = 26
objPushPin.Highlight = True
' objPushPin.Note = "This is the address you selected!"
End If
End Sub
RunTime error 4008
Method 'Addpushpin' of object '_Map' failedHere is Map load in frmMain Form
MappointControl1.NewMap geoMapNorthAmerica
Dim MapPointMap
Dim MapAutoZoom As String
Dim MapCountry As String
Dim MapCity As String
Dim MapVol As String
Dim routing As String
Dim GpsPort
GpsPort = GpsComm
'Try to load las map (if any)
If Dir(MyPath + "mappoint.ptm") <> "" Then
Me.MappointControl1.OpenMap MyPath + "mappoint.ptm"
Else
'Create Map
MappointControl1.NewMap MapPointMap
MappointControl1.ActiveMap.MapStyle = geoMapStyleRoad
End If
GpsPort = 4
MapPointMap = 1
MapAutoZoom = True
MapCountry = "Canada"
MapCity = "Markham"
MapVol = 1
routing = True
MappointControl1.Visible = True
' MappointControl1.PaneState = geoPaneRoutePlanner
Eric Frost
02-12-2011, 06:41 PM
Not sure... do you know how to do debugging and check the variable values at each step?
Eric
planethax
02-13-2011, 05:49 PM
Not sure... do you know how to do debugging and check the variable values at each step?
Eric
Not exactly sure on how to do that, I am googling it now.
Since the only difference between the Msdn example and my app is the Load sub, so I am thinking I have something wrong in there.
Maybe I will start eliminating 1 item at a time.
planethax
02-13-2011, 08:12 PM
Not sure where I got this line from or what is was supposed to do, but this was the line causing my error
MapPointMap = 1
Eric Frost
02-13-2011, 10:05 PM
Hmm, yeah sounds like a typo.
Would you consider preparing a short article for us about your experience with MapPoint programming for your CarPC?
Eric
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by
vBSEO 3.6.1