Google Maps API and links

I am trying to add a link to a popup bullet text bubble in Google Maps via an API. I have successfully followed the below code:

echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College&lt;br&gt;Link to Admissions" label="Albertus Magnus College" />';

      

But as soon as I actually try to add the link, it fails. Like this:

echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College&lt;br&gt;&lt;a href='http://www.albertus.edu/admission/index.shtml'&gt;Admissions&lt;\/a&gt;" label="Albertus Magnus College" />';

      

Does anyone know how to write this code successfully? I am writing it in PHP because I have some other functions that will prevent me from just writing it in XML.

Update: for some reason I did this ...

$window2a_url = '&lt;a href=&apos;http://www.albertus.edu/admission/index.shtml&apos;&gt;Admissions';
echo '<marker lat="41.331304" lng="-72.921438" html=" Albertus Magnus College&lt;br&gt;';
echo $window2a_url;
echo '" label="Albertus Magnus College" />';

      

I had to avoid apostrophes ... If anyone has a more elegant solution, I'm all ears!

+1


source to share


4 answers


This is the answer:

$window2a_url = '&lt;a
href=&apos;http://www.albertus.edu/admission/index.shtml&apos;&gt;Admissions';
echo '<marker lat="41.331304" lng="-72.921438" html=" Albertus Magnus College&lt;br&gt;';
echo $window2a_url;
echo '" label="Albertus Magnus College" />';

      



I had to avoid apostrophes ...

+1


source


You seem to be putting the apostrophe (') inside the string. You must use the escape character (maybe "\", I don't know PHP syntax) next to the apostrophe.



+1


source


what the other person said.

try:

echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College&lt;br&gt;&lt;a href=\'http://www.albertus.edu/admission/index.shtml\'&gt;Admissions&lt;\/a&gt;" label="Albertus Magnus College" />';

      

0


source


The problem is friol indicates you end echo using apastophe in the link, the code below should work because I escaped 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" />';

      

0


source







All Articles