Trouble with "&" in URL string for Google Maps
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 75
- Joined: Wed Mar 09, 2011 6:48 pm
- Location: Northern California
Trouble with "&" in URL string for Google Maps
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Trouble with "&" in URL string for Google Maps
Hi Gene,
It's not the "&" as you have it in quotes, makes it a string no longer a keyword (reserved word).
Gives me something back.
Simon
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
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 75
- Joined: Wed Mar 09, 2011 6:48 pm
- Location: Northern California
Re: Trouble with "&" in URL string for Google Maps
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
Thanks again,
Gene
Re: Trouble with "&" in URL string for Google Maps
Hi Gene,
Do you have the script across two lines as it works as expected for me when on a single line e.g.
This could be why it is working for Simon as well.
Kind Regards,
Neil Roger
--
LiveCode Tech Support
--
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
Kind Regards,
Neil Roger
--
LiveCode Tech Support
--
-
- VIP Livecode Opensource Backer
- Posts: 75
- Joined: Wed Mar 09, 2011 6:48 pm
- Location: Northern California
Re: Trouble with "&" in URL string for Google Maps
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
Thanks
-
- Posts: 1
- Joined: Fri Feb 06, 2015 3:56 am
- Location: Mayfield Heights
- Contact:
Re: Trouble with "&" in URL string for Google Maps
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.
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
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
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
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")
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Trouble with "&" in URL string for Google Maps
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.