我带来谷歌的代码来纠正它适合我的需要代码是固定lat长在图像的中心我想发送变量来设置中心 我发送变量lat long但我的代码是错误
第45行是我改变的代码,也许是问题请帮助
解析错误:语法错误,第82行的/home/thaimayor/domains/thaimr.com/public_html/mapSisthorn/google/samuitet2.php意外结束
<?php // RAY_temp_teera.php
error_reporting(E_ALL);
// GET THE VARIABLES OR SET DEFAULT VALUES
$lat = (empty($_GET["lat"])) ? 0.0 : $_GET["lat"];
$lon = (empty($_GET["lon"])) ? 0.0 : $_GET["lon"];
// CREATE THE HTML STRING
$htm = <<<HTM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps AJAX + MySQL/PHP Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAwlTHfy96hHQkgNbKq5-RuBQagu-oIqMKXX4Fc4TvxpP4f1DXQhTXRsWbAuJyc9boRX8CpgPHemLS6w"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var iconBlue = new GIcon();
iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);
var iconRed = new GIcon();
iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
iconRed.iconSize = new GSize(12, 20);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);
var customIcons = [];
customIcons["restaurant"] = iconBlue;
customIcons["bar"] = iconRed;
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng($lat,$lon), 12);
GDownloadUrl("phpsqlajax_genxml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var picname = markers[i].getAttribute("picname");
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, name, address, type, picname);
map.addOverlay(marker);
}
});
}
}
function createMarker(point, name, address, type, picname) {
var marker = new GMarker(point, customIcons[type]);
var html = "<b>" + name + "</b> <br/>" + address+"<br /><img src='"+picname+"' />";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 800px; height: 600px"></div>
</body>
</html>
答案 0 :(得分:1)
你忘记了结束
HTM;
在您的HEREDOC结束时。你无法省略,就像你不能省略结束}
一样。您可以在PHP中省略的唯一结束标记是?>
。
答案 1 :(得分:1)
答案 2 :(得分:1)
你只是错过了最后一行。
HTM;