Page 1 of 1
Trouble with "&" in URL string for Google Maps
Posted: Tue Feb 03, 2015 6:31 am
by Gene
I'm trying to display a Google Map in my Android app with Google Static Maps. The parameters in the string to be sent in the URL require ampersands, but the Livecode compiler rejects the code because the "&" character is a reserved keyword. At least, that's what I think is happening when I get the error.
Here is the string I'm trying to use: mobileControlSet browserID, "url", "
https://maps.googleapis.com/maps/api/st ... ze=400x400&
markers=color:blue%7Clabel:S%7C38.98,-122.75" Notice the ampersands that Google uses as delimiters in the parameters.
Them compiler just laughs at me and says, "button "Button": compilation error at line 7 (Script: missing '"' after literal), char 1"
So, am I correct in my assessment of the problem, and if so, is there a workaround?
Much thanks in advance!
Gene
Re: Trouble with "&" in URL string for Google Maps
Posted: Tue Feb 03, 2015 7:59 am
by Simon
Hi Gene,
It's not the "&" as you have it in quotes, makes it a string no longer a keyword (reserved word).
Code: Select all
on mouseUp
put url "https://maps.googleapis.com/maps/api/staticmap?center=38.98,-122.75&zoom=13&size=400x400&markers=color:blue%7Clabel:S%7C38.98,-122.75"
end mouseUp
Gives me something back.
Simon
Re: Trouble with "&" in URL string for Google Maps
Posted: Tue Feb 03, 2015 9:37 am
by Gene
Thank you, Simon, for replying so quickly. Just as you say, I assumed that placing the string in quotes would encapsulate keywords and insulate them from errors. Given the text of the error I am getting, do you have any ideas of what could be generating the error. I cited the error in my original message.
Thanks again,
Gene
Re: Trouble with "&" in URL string for Google Maps
Posted: Tue Feb 03, 2015 1:15 pm
by LCNeil
Hi Gene,
Do you have the script across two lines as it works as expected for me when on a single line e.g.
Code: Select all
on mouseUp
put "https://maps.googleapis.com/maps/api/staticmap?center=38.98,-122.75&zoom=13&size=400x400&markers=color:blue%7Clabel:S%7C38.98,-122.75"
end mouseUp
This could be why it is working for Simon as well.
Kind Regards,
Neil Roger
--
LiveCode Tech Support
--
Re: Trouble with "&" in URL string for Google Maps
Posted: Thu Feb 05, 2015 2:24 am
by Gene
Thanks folks for the help. As suggested, the problem was with an embedded carriage return in the line. I copied and pasted the script and somehow didn't detect it. Everything is working fine now.
Thanks
Re: Trouble with "&" in URL string for Google Maps
Posted: Fri Feb 06, 2015 6:59 am
by puppypaws0123
hi new here
Does anyone connect to google app engine site from livecode? I'm thinking about using google app engine to host the multiplayer/server stuff for my games and apps.
Re: Trouble with "&" in URL string for Google Maps
Posted: Fri Feb 06, 2015 2:01 pm
by Klaus
Hi puppypaws,
1. welcome to the forum!
2. I might be better to start a new thread than to hijack an already SOLVED one!
But what on earth is the "google app engine site"?
Best
Klaus
Re: Trouble with "&" in URL string for Google Maps
Posted: Wed Mar 04, 2015 5:50 pm
by MaxV
How about this?
Code: Select all
mobileControlSet browserID, "url", merge("https://maps.googleapis.com/maps/api/staticmap?center=38.98,-122.75&zoom=13&size=400x400&markers=color:blue%7Clabel:S%7C38.98,-122.75")
Re: Trouble with "&" in URL string for Google Maps
Posted: Sat Mar 21, 2015 12:03 am
by GSPearson
This is why in my map application I am using Leaflet.js and OpenStreetMaps for my mapping requirements as it is so much easier to place a marker and details about the marker.