Trouble with "&" in URL string for Google Maps

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Gene
VIP Livecode Opensource Backer
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

Post by Gene » Tue Feb 03, 2015 6:31 am

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

Simon
VIP Livecode Opensource Backer
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

Post by Simon » Tue Feb 03, 2015 7:59 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gene
VIP Livecode Opensource Backer
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

Post by Gene » Tue Feb 03, 2015 9:37 am

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Trouble with "&" in URL string for Google Maps

Post by LCNeil » Tue Feb 03, 2015 1:15 pm

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
--

Gene
VIP Livecode Opensource Backer
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

Post by Gene » Thu Feb 05, 2015 2:24 am

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

puppypaws0123
Posts: 1
Joined: Fri Feb 06, 2015 3:56 am
Location: Mayfield Heights
Contact:

Re: Trouble with "&" in URL string for Google Maps

Post by puppypaws0123 » Fri Feb 06, 2015 6:59 am

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.

Klaus
Posts: 12008
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Trouble with "&" in URL string for Google Maps

Post by Klaus » Fri Feb 06, 2015 2:01 pm

Hi puppypaws,

1. welcome to the forum! :D
2. I might be better to start a new thread than to hijack an already SOLVED one! 8)

But what on earth is the "google app engine site"?


Best

Klaus

MaxV
Posts: 1577
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Trouble with "&" in URL string for Google Maps

Post by MaxV » Wed Mar 04, 2015 5:50 pm

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

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: Trouble with "&" in URL string for Google Maps

Post by GSPearson » Sat Mar 21, 2015 12:03 am

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.

Post Reply

Return to “Internet”