Javascript 如何在小地图中心设置谷歌地图<;部门>;?
如何将谷歌地图设置在一个小地图的中心Javascript 如何在小地图中心设置谷歌地图<;部门>;?,javascript,maps,Javascript,Maps,如何将谷歌地图设置在一个小地图的中心? 下面是代码 下面的代码工作正常,但城市显示在 如何将其移动到 谷歌地图 功能显示位置(地址) { var-map=null; var-geocoder=null; if(GBrowserIsCompatible()){ VarMap=newGMAP2(document.getElementById(“map_canvas_small”); geocoder=新的GClientGeocoder(); if(地理编码器){ geocoder.getLatLn
?
下面是代码
下面的代码工作正常,但城市显示在
如何将其移动到
谷歌地图
功能显示位置(地址)
{
var-map=null;
var-geocoder=null;
if(GBrowserIsCompatible()){
VarMap=newGMAP2(document.getElementById(“map_canvas_small”);
geocoder=新的GClientGeocoder();
if(地理编码器){
geocoder.getLatLng(
地址:,
功能(点){
如果(!点){
警报(地址+“未找到”);
}否则{
地图设定中心(点13);
}
}
);}
}
}
{
展览地点(“西班牙马德里”);
}
您使用什么浏览器?
我在不同的浏览器中测试您的代码,并正常居中。
也许问题是浏览器还是操作系统
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Google Map</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAdsfdspeATWBO-DG9lMgJ0ShhR6-O8wdUc0uGLMinc7m1CWtOdsfdsfsdqG9fPRwilSPzZoK_0Q" type="text/javascript"></script>
<script type="text/javascript">
function showLocation(address)
{
var map = null;
var geocoder = null;
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas_small"));
geocoder = new GClientGeocoder();
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found .");
} else {
map.setCenter(point , 13);
}
}
);}
}
}
</script>
</head>
<body onunload="GUnload()">
<div id="map_canvas_small" style="width: 208px; height:80px "></div>
<script type="text/javascript">
{
showLocation('Madrid, Spain');
}
</script>
</body>
</html>