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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping Software Example 1

Status
Not open for further replies.

gbettle

Programmer
Nov 23, 2005
33
0
0
DK
Howdy all,

I've used in the past an example form wrapping the mapping services of two websites. It returned the webpage inside of the form, therefore, it wasn't a "true" webservice. It was using maps.google.com and I think multimap.com (NB: the last website I'm not entire sure of). You gave it a From Postcode and To Postcode, and it returned the directions.

I can't find the example anymore - does anyone else have this example or know where to find it?

Cheers,

Garry
 
Hi Garry

Sometime ago, our friend craigsboyd gave an example on this thread: thread1251-1209236

Is that what your looking for or can it assist?

Good luck

Lee


Windows XP
Visual FoxPro Version 6 & 9
 
Hi Lee,

Many thanks for your reply. It looks promising but I don't this it is.

I'm pretty sure it wasn't using Google Earth - it was Google Maps & purely for directions between two locations.

Could still have been Craig though ... Craig, are you there?

Cheers,

Garry
 
I have some examples that use mappoint automation for returning directions if this is of interest to you I can give an example

Steve Bowman
Independent Technology, Inc.
CA, USA
 
parsing HTML always runs the risk that the page changes and your anchors fail...

Brian

Code:
cStartAddress = "123 Main Street MyTown MyState MyZip"
cDestAddress = "123 Oak Street MyTown MyState MyZip"

google_directions(cStartAddress, cDestAddress)

PROCEDURE google_directions
LPARAMETERS tcStartAddress, tcDestAddress 
LOCAL CRLF, cUrl, oHTTP, nStart, nEnd, cResult, cTag, lTag, oIE
  STORE CHR(13)+CHR(10) TO CRLF

  Set Library To Home()+"Foxtools.fll"  additive
  tcStartAddress=CHRTRAN(ALLTRIM(reduce(tcStartAddress)),CHR(32),"+")
  tcDestAddress =CHRTRAN(ALLTRIM(reduce(tcDestAddress )),CHR(32),"+")

  cURL = "[URL unfurl="true"]http://www.google.com/maps?f=d&hl=en&saddr="[/URL] + tcStartAddress + "&daddr=" + tcDestAddress 

  oHTTP = CreateObject([MSXML2.XMLHTTP])
  oHTTP.Open("GET", cURL, .f.)
  oHTTP.Send
  cResult=(oHTTP.ResponseText)

  nStart = ATC("<table class=\042dirsegment\042>", cResult, 1)
  cResult = SUBSTR(cResult, nStart , LEN(cResult)- nStart)
  nEnd = ATC("afterRoute\", cResult, 1)
  cResult = STRTRAN(LEFT(cResult, nEnd)+">", "<br>", " ")
  cResult = STRTRAN(cResult,"&#160;", SPACE(3))

  &&remove Html Tags
  lTags = .t.
  DO WHILE lTags 
    nStart = ATC("<", cResult, 1)
    nEnd = ATC(">", cResult, 1)
    cTag = SUBSTR(cResult, nStart, 1 + nEnd - nStart)
    cResult = STRTRAN(cResult, ctag, IIF(LOWER(ctag)=="</td>", CRLF,""))
    
    IF OCCURS("<",cResult)>0 AND OCCURS(">",cResult)>0
      lTags = .t.  
    ELSE
      lTags = .f.
    ENDIF 
  ENDDO

  IF LEN(cResult)=1 &&troubleshoot
    oIE = CREATEOBJECT("InternetExplorer.Application")
    oIE.Navigate2(cURL)
    oIE.visible=.t.
    MESSAGEBOX("See what went wrong.", 0, "", 15000)
    oIE.Quit
  ELSE
    && sucess
    STRTOFILE(cResult,"cut.txt") 
    MODIFY FILE cut.txt nowait
  ENDIF 
ENDPROC
 
I am totally amazed at this code - it has given me precise directions here in Adelaide Australia from home to Brisbane on the other side of the country - and the shortest road route too!.

Q 1 Can the total distance be calculated ( ie adding all the steps.

Q 2 Can I simply bring up a map with a pointer to a location through code?

Regards

Bryan
 
I now have the map working - in the above code

Code:
 cURL = "[URL unfurl="true"]http://www.google.com/maps?f=d&hl=en&saddr="[/URL] + tcAddress 

  oHTTP = CreateObject([MSXML2.XMLHTTP])
  oHTTP.Open("GET", cURL, .f.)
  oHTTP.Send
  cResult=(oHTTP.ResponseText)
  
STRTOFILE(cResult, 'map.htm') 
DECLARE INTEGER ShellExecute ;
		IN SHELL32.DLL ;
		INTEGER nWinHandle,;
		STRING cOperation,;
		STRING cFileName,;
		STRING cParameters,;
		STRING cDirectory,;
		INTEGER nShowWindow

ShellExecute(0,"open",'map.htm' ,"","",1)

I would like to get the lat and long really.


And total distance would still be useful

Regards

Bryan

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top