Anonymous
11-06-2004, 11:07 AM
I have MapPoint 2001, Can I manipulate this w/ VB(A) to retrieve the Lat, Lon, Distance, route Milesage etc. I am reasonably proficient w/ the various'flavors" of VB(A) and VB itself, but have noted the numerous recommendations to upgrade to at least ver "X" (all well beyond 2001). Unfortunatly, I would be hard pressed to afford the cost as I am retired and have a limited income. The obnly 'reference' I see within the help files concerns generating a com add in to instantiate as a menu item. It doesn't even begin to list the data elements which could then be manipulated via the menu item (re the above)
Anonymous
11-08-2004, 01:48 PM
:( Since the original posting, I have struggled to get through the exercise. I have browsed through over 1/2 of the messages and articles posted here in, extracting several to numerous routines and combining them with the (skimpy?) examples from (MapPoint) Help. The Calc Position routine with some help file stufff ... ffff gets a map open (even on screen! - Which I do not really need), and -given a LITERAL for the place to find setting a location object, it will return (calculate) a (single) Lat & Lon. I cannot sem to devise any way to have FIND use a calculated string or string variable. If any one can suggest WHAT the (*&!#$^(*&#^$(A@^( I am doing wrong it would be SISNCERELY appreciated. It would be almost sincerely appreciated If you could even DEFINITIVELY state that Find CANNOT accept anything BUT the literal argument (although THAT seems to make the method of the object USELESS!!!! (?)
Public Function basOpenMap(MapPath As String) As Boolean
'Michael Red 11/5/04 First try from Help Exapmples
Dim objMapApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRs As MapPoint.Recordset
Dim objData As MapPoint.DataSet
Dim objLoc As MapPoint.Location
Dim PPinLoc As MapPoint.Location
Dim ILat As Double
Dim iLon As Double
Set objMapApp = New MapPoint.Application
Set objMap = objMapApp.NewMap
Dim Idx As Integer
objMap.SaveAs objMapApp.DefaultFilePath & "\Map.Ptm", geoFormatMap
objMapApp.NewMap
Set objMap = objMapApp.OpenMap(objMapApp.DefaultFilePath & "\" & MapPath & ".PTM")
Set objRs = objMapApp.OpenMap(objMapApp.DefaultFilePath & "\" & MapPath & ".PTM") _
.DataSets("qrySelFlZips").QueryAllRecords
Set objData = objMap.DataSets("qrySelFlZips")
objData.DisplayPushpinMap
'From LITERAL ONLY
Set objLoc = objMap.Find("Tampa, FL")
Call CalcPos(objMap, objLoc, ILat, iLon) '<-Works
Debug.Print ILat, iLon
'From ana attempt to get the several via the string VARIABLE
While Idx < objData.RecordCount
Set PPinLoc = objMap.Find(Chr(34) & objRs.Fields(1) _
& ", FL" & Chr(34))
Call CalcPos(objMap, PPinLoc, ILat, iLon) '<-Works NOT
Debug.Print objRs.Pushpin.Name, objRs.Fields(1), ILat, iLon 'Gives Zip Code (PK) and Name
objRs.MoveNext
Idx = Idx + 1
Wend
End Function
John Meyer
11-09-2004, 06:03 AM
Its good advice to upgrade to MapPoint 2002. It will be frustrating trying to get stuff to work and it will be hard to help you with 2001. (I don't even have a copy anymore I dont think) Everyone uses 2002 or 2004. The big difference in 2004 is updated data. You may be able to get a copy of MapPoint 2002 on ebay for a good price.
I did notice in you code sample that you opened/created the map 4 times?
Set objMap = objMapApp.NewMap
objMapApp.NewMap
Set objMap = objMapApp.OpenMap(objMapApp.DefaultFilePath & "\" & MapPath & ".PTM")
Set objRs = objMapApp.OpenMap(objMapApp.DefaultFilePath & "\" & MapPath & ".PTM") _ .DataSets("qrySelFlZips").QueryAllRecords
Anonymous
11-09-2004, 08:24 AM
John,
Thanks for at least SOME response. By continued 'due duilengence', I am (S L O W L Y) getting somewhere. I can currently ge a large percentage of the points to work with a string variable using the FIND method. Approx 15% still baffle me. Using the "Find Dialog, I can enter the City name and State and ye olde (and apparently decripit?) MapPoint 2001 goes to the city. Putting the "Same" info in programatically with the string variable, the Finf METHOD fails to generate a Location object. I think much of my earlier difficulty in the use of the string var was the weird, non-standard error handling from MapPooint (at least ver '01). When the methods fail, they do not error, but set the opbject to nothing, but the Distance method fails and returns an actual error. I did eventually find [/b]Is Nothing and can trap the occurance of the failure to find and prevent (ByPass) the call to CalcPos.
Alas. Alack and Awry I still can't figure out WHY the find method fails -particularly so often. My first thought was that find was not able to (uniquely) resolve the City-State in htese instances, however using hte text box entry shows tha somewhere over (or at least near) 90% of hte entries return multiple locations, so this appears to not be the basic issue. I haven't yet attempted to Include the Zip code as part of location to Find, however this would be -at best- problematical, as Zip Codes are subject to change and I do not seem to have a reliable (and FREE) source enyway. I MAY go back and re-try t he FinAddress method, but so far at least is is even MORE frostrating than Find, as it SEEMS LIKE the "Street" argument is required. This might be good for a greater level of detail, but I'm only trying to get a general set of locations (to Zip code today, perhaps to census tracts later), not specific street addresses (e.g. not a single building), so I do not even have street names, or bulding / lot information to try this with.
I am just starting to manipulate MapPoint, and the code I posted is the progressive results of attempting to combine the various snippets from MApPoing (programming) help (Properties and Methods). I haven't quite yet slowed down enough to get the understanding of the differences in the various methods of instantiating the specific Map. I will review the code a bit and see if I can reduce the number of occurances of instantiating map, In particular, I would like to avoid instantiating the application as a visible object (Window), ofr at least destroy it when the routine(s) are complete.
Thanks, again, for responmding,
Michael Red