Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在小地图中心设置谷歌地图<;部门>;?_Javascript_Maps - Fatal编程技术网

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&amp;v=2&amp;sensor=true&amp;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>