Hello,
I am trying to add a link into the pop-up text bubble of a marker in Google Maps through the API. I have successfully run the below code:
echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College<br>Link to Admissions" label="Albertus Magnus College" />';
But once I actually try to add the link it fails. Like this:
echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College<br><a href='http://www.albertus.edu/admission/index.shtml'>Admissions<\/a>" label="Albertus Magnus College" />';
Does anyone know how to successfully write this code? I am writing it into PHP because I have some other functionality that won't let me just write it in XML.
Update: I got it to work like this for some reason...
$window2a_url = '<a href='http://www.albertus.edu/admission/index.shtml'>Admissions';
echo '<marker lat="41.331304" lng="-72.921438" html=" Albertus Magnus College<br>';
echo $window2a_url;
echo '" label="Albertus Magnus College" />';
I had to escape the apostrophes... If anyone has a more elegant solution, I am all ears!
-
Seems you are putting an apostrophe (') inside the string. You should use an escape character (may be "\", I don't know PHP's syntax) near the apostrophe.
JoshFinnie : for some reason when I tired that I still got an error. But you were right about the "\" being PHP's escape character. -
what the other chap said.
try:
echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College<br><a href=\'http://www.albertus.edu/admission/index.shtml\'>Admissions<\/a>" label="Albertus Magnus College" />'; -
The problem is as friol indicates that you end the echo using an apastophe in the link, the code below should work because I escaped the apastrophe (' to \')
echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College<br><a href=\'http://www.albertus.edu/admission/index.shtml\'>Admissions</a>" label="Albertus Magnus College" />'; -
This is the answer:
$window2a_url = '<a href='http://www.albertus.edu/admission/index.shtml'>Admissions'; echo '<marker lat="41.331304" lng="-72.921438" html=" Albertus Magnus College<br>'; echo $window2a_url; echo '" label="Albertus Magnus College" />';I had to escape the apostrophes...
0 comments:
Post a Comment