我正在尝试在我的网站中实现谷歌地图标记。但它只显示一个蓝屏和一个标记。我在那里看不到任何地图。请在下面查看我的代码。我已经用 mykey 替换了 apikey。
<?
define("MAPS_HOST", "maps.google.com");
define("KEY", "mykey"); // Place your API Key here...
// Get our address (from a database query or POST
$address = "india";
// Build our URL from the above...
$base_url = "http://" . MAPS_HOST . "/maps/geo?q=" . $address . "&output=csv" . "&key=" . KEY;
// Initalise CURL
$c = curl_init();
// Get the URL and save the Data
curl_setopt($c, CURLOPT_URL, $base_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
// Save location data
$csvPosition = trim(curl_exec($c));
// Close the connection
curl_close($c);
// Split pieces of data by the comma that separates them
list($httpcode,$elev, $lat, $long) = preg_split("/[,]+/", $csvPosition);
?>
<!DOCTYPE html>
<html>
<head>
<title>Geocoding Example - WinSysAdminBlog.com</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
#map_canvas { height: 512px; width: 512px; }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $long; ?>);
var addressMarker = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $long; ?>);
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
marker = new google.maps.Marker({ map:map, position: addressMarker });
}
</script>
</head>
<body onload="initialize()">
<h2>Geocoding Example</h2>
<div id="map_canvas"></div>
</body>
</html>
提前致谢。真诚的,苏尼尔