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<br>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<br><a href='http://www.albertus.edu/admission/index.shtml'>Admissions<\/a>" 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 = '<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 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 = '<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 avoid apostrophes ...
+1
source to share
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 to share