Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GOOGLE/MAPQUEST Question 5

Status
Not open for further replies.

WIREMESH

Programmer
Mar 15, 2004
109
US
Using any type of mapping API(Google, MApquest/Microsoft, etc.) I want to able to track the distance traveled between sites.

For instance (3 SAMPLE SITES)

starting site1: 1500 Market St, Phila PA 19102
site2: 5712 Broomall st. Phila pa 19143
site3: 1213 North st. cAMDEN, NJ 11111

The results would be distance traveled from sitex to sitey to is xxx.xx miles.

How can this be accomplished using any of the web api's using VFP?
 
Steve,
When I enter some addresses I get the type mismatch error:

ex.

lc_address1 = "RT 113 & STATE R, MILLSBORO,DE,19966"
lc_address2 = "951 N DUPONT BLD,MILFORD,DE,19963"


is there anyway to have the algorithm not generate the runtime error? I can trap the error code but since I have to run thru several start & end dates, I would prefer a more graceful way of saying the address is bad rather than the runtime error.
 
i looks like the issue is that
If Type("goLoc1")="O" .and. Type("goLoc2")="O"

both evaluate to Object even though in this case goLoc1 is not due to a bad address. if you try to use the goLoc1 it is NOT an Object. Strange indeed, what i have found in this case is.
? TYPE("goloc1.Latitude")="U"
? TYPE("goloc2.Latitude")="N"
this would be correct, in a found location Latitude would be numeric. So without a lot of testing I would change the
Code:
If [COLOR=red]Type("goLoc1")="O" .and. Type("goLoc2")="O"[/color]
    myDistance1=goMap.Distance(goLoc1, goLoc2)
ELSE
    myDistance1=0
ENDIF

If [COLOR=red]Type("goLoc1")="O" .and. Type("goLoc2")="O"[/color]
    goRoute = goMap.ActiveRoute 
    goRoute.Clear()        && Get rid of any existing waypoints.
    goRoute.Waypoints.Add(goLoc1)
    goRoute.Waypoints.Add(goLoc2)
    goRoute.Calculate()    && Compute the route and get directions.
    myDistance2 = goRoute.Distance
ELSE
    myDistance2=0
ENDIF
TO
Code:
If [COLOR=blue]TYPE("goloc1.Latitude")="N" .and. TYPE("goloc2.Latitude")="N"
[/color]    myDistance1=goMap.Distance(goLoc1, goLoc2)
ELSE
    myDistance1=0
ENDIF

If [COLOR=blue]TYPE("goloc1.Latitude")="N" .and. TYPE("goloc2.Latitude")="N"
[/color]    goRoute = goMap.ActiveRoute 
    goRoute.Clear()        && Get rid of any existing waypoints.
    goRoute.Waypoints.Add(goLoc1)
    goRoute.Waypoints.Add(goLoc2)
    goRoute.Calculate()    && Compute the route and get directions.
    myDistance2 = goRoute.Distance
ELSE
    myDistance2=0
ENDIF



Steve Bowman
Independent Technology, Inc.
CA, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top