Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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 Google Map API,Geocoder.GetLocations始终返回“浏览器不兼容”_Javascript_Google Maps_Google Geocoder - Fatal编程技术网

Javascript Google Map API,Geocoder.GetLocations始终返回“浏览器不兼容”

Javascript Google Map API,Geocoder.GetLocations始终返回“浏览器不兼容”,javascript,google-maps,google-geocoder,Javascript,Google Maps,Google Geocoder,我使用的是基于JavaScript的谷歌地图API,当我尝试使用geocoder.getlocations时,它会返回浏览器不兼容异常并卸载地图。请看一下我的代码,让我知道它有什么问题 function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GSmallMapControl()

我使用的是基于JavaScript的谷歌地图API,当我尝试使用geocoder.getlocations时,它会返回浏览器不兼容异常并卸载地图。请看一下我的代码,让我知道它有什么问题

function initialize() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GNavLabelControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

    geocoder = new GClientGeocoder();
  }
}

function showAddress(address) {
var zipcodex = 0;
if(geocoder)
{
    geocoder.getLocations(address, getzip); 

function getzip (response) 
    {
    if (!response || response.Status.code != 200)
        {
        alert("Sorry, we were unable to geocode the first address");
        }
    else
        {
        if(response.Placemark[0].AddressDetails.Country.AdministrativeArea.
        Locality.PostalCode.PostalCodeNumber)
            {
            zipcodex = response.Placemark[0].AddressDetails.Country.AdministrativeArea.
            Locality.PostalCode.PostalCodeNumber;
            } 

        }

    }
}

  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
          map.setCenter(point, 13);
          var marker = new GMarker(point);
          map.addOverlay(marker);
    if(zipcode)
    {
    marker.openInfoWindowHtml('Zipcode:'+zipcodex);
    }
    else
    {
        marker.openInfoWindowHtml(address);
    }
        }
      }
    );

  }
}    

我建议您使用谷歌地图API的第3版,除非您有理由坚持使用第2版。请尝试以下示例:


我想这并不能解决我的问题