LiveCode & google maps...

John Dixon dixonja at hotmail.co.uk
Tue Feb 15 12:41:53 EST 2011


Peter,

Thanks for this... 

regards,

John Dixon

> From: pmbrig at gmail.com
> To: use-livecode at lists.runrev.com
> Subject: Re: LiveCode & google maps...
> Date: Tue, 15 Feb 2011 10:56:56 -0500

> Here is a function I have used to fetch the total distance between two  
> addresses from Google maps. The function returns the distance without  
> displaying any map, but you could play with the script to also display  
> the map.
> 
> --------
> 
> function getMileage
>     put "http://maps.googleapis.com/maps/api/directions/xml?" & \
>            "origin=<tOrig>&destination=<tDest>&sensor=false" into tURL
>     put fld "from" into tStart
>     put fld "to" into tEnd
>     replace "<tOrig>" with urlEncode(tStart) in tURL
>     replace "<tDest>" with urlEncode(tEnd) in tURL
>     put URL tURL into t
>     put lineoffsets("<distance>",t) into startSect
>     put item -1 of startSect into startSect
>     put lineoffsets("</distance>",t) into endSect
>     put item -1 of endSect into endSect
>     if startSect = 0 or endSect = 0 then
>        beep
>        exit to top
>     end if
>     put line startSect+1 to endSect-1 of t into tSect
>     put lineoffset("<text>",tSect) into dLine
>     if dLine = 0 then
>        beep
>        exit to top
>     end if
>     put sr(line startSect + dLine of t) into tMiles
>     --   <text>3.6 mi</text>
>     replace "<text>" with empty in tMiles
>     delete word -1 of tMiles
>     return tMiles
> end getMileage
> 
> -- Peter
> 
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
 		 	   		  


More information about the Use-livecode mailing list