本文发表在 rolia.net 枫下论坛以下的例子是在BROWSER 中显示GOOGLE MAP
但只在FIREFOX 中其作用, 在IE 中无法正常显示地图.
<!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 JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAO113DyqaH8gwQoTmNM6gmRQXq7bWTC04Ff1KKaIsErBhwE7B5xRebjx7TLK2_insr0ibSHfwHKCLaw"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map = null;
var geocoder = null;
var mapPoint = null;
var addr = "40 murmouth road, toronto, canada";
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
showAddress(addr);
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(newPoint) {
if (!newPoint) {
alert(address + " not found");
} else {
//alert(address + " found");
map.setCenter(newPoint, 13);
var marker = new GMarker(newPoint);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
mapPoint = newPoint;
}
);
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="margin: 10px; left: 10px; width: 100%; position: absolute; top: 10px; height: 100%;">
</div>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
但只在FIREFOX 中其作用, 在IE 中无法正常显示地图.
<!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 JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAO113DyqaH8gwQoTmNM6gmRQXq7bWTC04Ff1KKaIsErBhwE7B5xRebjx7TLK2_insr0ibSHfwHKCLaw"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map = null;
var geocoder = null;
var mapPoint = null;
var addr = "40 murmouth road, toronto, canada";
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
showAddress(addr);
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(newPoint) {
if (!newPoint) {
alert(address + " not found");
} else {
//alert(address + " found");
map.setCenter(newPoint, 13);
var marker = new GMarker(newPoint);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
mapPoint = newPoint;
}
);
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="margin: 10px; left: 10px; width: 100%; position: absolute; top: 10px; height: 100%;">
</div>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net