Note: This technique can be also done using a VFP class rather then a DLL. Note 2 :MapQuest is a website that allows you to find a portion of a map that contains the address,city, country and zip code requested. This has been tested for Canada and the US.
Create a directory with Windows Explorer and call the directory "mapquest".
In FoxPro poit the default directory to the "mapquest" directory. Tolls->Options->File locations->Default directory.
Create a blank project (do not use the project wizard), and call the project "mapquest".
Add a custom class (called "internet").
Add 3 methods to the custom class (searchURL,showdestination,URLencode).
In the 'searchURL" method put the following code: LPARAMETERS tcURL oBrowser = CREATEOBJECT("internetexplorer.application") oBrowser.navigate(tcURL) oBrowser.visible = .t.
In the 'showDestination' method put the following code: LPARAMETERS lcStreet,lcCity,lcState,lcZip,lcCountry IF EMPTY(lcStreet) lcStreet = "" ENDIF IF EMPTY(lcState) lcState = "" ENDIF IF EMPTY(lcZip) lcZip = "" ENDIF IF EMPTY(lcCountry) lcCountry = "US" ENDIF IF EMPTY(lcCity) lcCity="" ENDIF this.searchurl("http://www.mapquest.com/maps/map.adp?country=" + ; lcCountry + "&addtohistory=&address=" + ; this.UrlEncode(lcStreet) + ; "&city=" + this.UrlEncode(lcCity) + "&state=" + ; this.UrlEncode(lcState) + "&zipcode=" + ; this.UrlEncode(lcZip) + "&homesubmit=Get+Map&size=big")
In the URLencode method put (this code was borrowed from www.West-Wind.com): LPARAMETERS tcValue, llNoPlus LOCAL lcResult, lcChar, lnSize, lnX lcResult="" FOR lnX=1 to len(tcValue) lcChar = SUBSTR(tcValue,lnX,1) IF ATC(lcChar,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") > 0 lcResult=lcResult + lcChar LOOP ENDIF IF lcChar=" " AND !llNoPlus lcResult = lcResult + "+" LOOP ENDIF lcResult = lcResult + "%" + RIGHT(transform(ASC(lcChar),"@0"),2) ENDFOR RETURN lcResult
Close the project. Open the class browser and load the internet class library and right-mouse on it and set it to OLEPublic. && This is required for a DLL
Re-open the project and compile it using the "multi-threaded COM server DLL."
Now you are ready to call the DLL to locate a portion of a map on mapQuest, using the 4 required parameters. In the command window try: oMap = NEWOBJECT("mapquest.internet") oMap.ShowDestination("134 ave Willobank","Pointe-claire","QC",; "H9R3K8","CA")
P.S. If the DLL is to be used on a user's computer rather than the development computer, the DLL needs to be registered.