|
Posted by Toby A Inkster on 06/18/07 11:08
phill.luckhurst@googlemail.com wrote:
> echo "var point = new GLatLng(" . $row['field_5'] . "," .
> $row['field_4'] . ");\n";
> echo "var marker = createMarker(point, '" .
> addslashes($row['field_1']) . "<br /><a href=\"" . $row['field_2'] . "
> \">". $row['field_2'] ."</a><br .>" . $row['field_3'] . "',3);\n";
> echo "map.addOverlay(marker);\n";
> echo "\n";
This kind of mess can be avoided by liberal use of printf.
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s<br /><a href=\"%s\">%s</a><br />%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes(htmlentities($row['field_1']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_2']))
, addslashes(htmlentities($row['field_3']))
);
Or better still:
$markertext = sprintf('%s<br /><a href="%s">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);
This makes it clear where to add your target="_blank":
$markertext = sprintf('%s<br /><a href="%s" target="_blank">%s</a><br />%s'
, htmlentities($row['field_1'])
, htmlentities($row['field_2'])
, htmlentities($row['field_2'])
, htmlentities($row['field_3'])
);
printf("var point = new GLatLng(%f, %f);\n"
."var marker = createMarker(point, '%s', 3);\n"
."map.addOverlay(marker);\n\n"
, $row['field_5']
, $row['field_4']
, addslashes($markertext)
);
Though I'd avoid creating a popup like this -- it breaks the "back"
button and confuses users.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 114 days, 18:42.]
You're Not Allowed to Take Pictures of the US Embassy in Rome
http://tobyinkster.co.uk/blog/2007/06/16/us-embassy/
[Back to original message]
|