As Mike mentioned, the API call returns image data, so set the filename of an 
image to the url. Here’s the script from a working demo:

on mouseUp
    put urlEncode(fld "address") into tAddress
    put urlEncode(fld "city") into tCity
    put urlEncode(fld "state") into tState

    put the thumbposition of scrollbar "scale" into tScale
    put the hilitedButtonName of group "maptype" into tType
    put ""; into tBaseURL
    put  "?center=" into tArgList
    if tAddress is empty then
        --put empty into tArgList
        put tAddress & comma after tArgList
    end if
    put tCity & comma & tState after tArgList
    put "&zoom=" & tScale & "&size=512x512&maptype=" & tType after tArgList

    # build marker
    put urlEncode(fld "m_address") into tMAddress
    put urlEncode(fld "m_city") into tMCity
    put urlEncode(fld "m_state") into tMState
    put the label of btn "color" into tMColor
    put toUpper(char 1 of fld "label") into tMLabel
    put "&markers=" & "color:" & tMColor & "|label:" & tMLabel & "|" & 
tMAddress,tMCity,tMState after tArgList

    put tBaseURL & tArgList into fld "urlfld"
    set the filename of img "map" to fld "urlfld"
end mouseUp

Most of the script is building a URL string with the proper arguments. The last 
two statements are where you actually display the image.

One thing I will say its that if you want to use it for other than just 
occasional demos, you will have to register with Google for an API key, when 
gets tacked on to the end of the argument list for the URL.

If you’d like you can grab the working stack here (from the message box):

go stack URL 

Hope this helps.


On Apr 27, 2017, at 2:49 PM, William Prothero via use-livecode 
<<>> wrote:

Turns out there is a Google Static Map api. I’m trying to use it, but get no 
response from my code that indicates an error.
The Static Maps API URL is: 

From the dictionary, it looks like I can do this: (this is the example in the 
google docs. It gives me a map when I put the URL into the browser).
on mouseUp

 put mapURL() into tURL

 put tURL

  put URL tURL into x

  put x into image  “myGMap” —This, obviously won’t work. See below.

end mouseUp

function mapURL

 into retURL

    return retURL

end mapURL

I get text back that looks like that below. It is obviously in some format I 
can decode in Livecode. I’ve just reached my comfort level with this. How 
should I decode this. so I can set the imagedata to it?
Bill P

—start of returned text


use-livecode mailing list<>
Please visit this url to subscribe, unsubscribe and manage your subscription 

Devin Asay
Office of Digital Humanities
Brigham Young University

use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription 

Reply via email to