Google maps 可视化地址时无法调用未定义的方法“getSouthWest”

Google maps 可视化地址时无法调用未定义的方法“getSouthWest”,google-maps,geocoding,Google Maps,Geocoding,我试图为用户在web表单中输入的地址显示一个标记。问题是我得到了以下错误 无法调用未定义的方法“getSouthWest” 当我尝试使用以下代码显示标记时: var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.O

我试图为用户在web表单中输入的地址显示一个标记。问题是我得到了以下错误

无法调用未定义的方法“getSouthWest”

当我尝试使用以下代码显示标记时:

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var latitude = results[0].geometry.location.lat();
            var longitude = results[0].geometry.location.lng();

                //Remove all markers from the map
            clearMarkers();

                //Display the new marker on the map
            showFullAddressesOnMap(latitude, longitude, address);

            //Center the map according to the marker
            map.fitBounds(results[0].geometry.bounds);                      
        }
    });

function showFullAddressesOnMap(latitude, longitude, fullAddress) {
    displayMarker(-1, "", "", "", fullAddress, true, latitude, longitude);
}

function displayMarker(appID, title, image, imageType, address, markerType, lat, lng) {

    var listingLatLng = new google.maps.LatLng(lat, lng);
    var marker = new google.maps.Marker({
        position: listingLatLng,
        map: map,
        icon: markerType ? imgBluePin : imgGreenPin,
        title: title + address
    });

    var content = GetContent(appID, title, image, imageType, address);

    marker.info = new google.maps.InfoWindow({
        content: content,
        size: new google.maps.Size(50, 50)
    });

    google.maps.event.addListener(marker, 'click', function () {
        closeAllWindows();
        marker.info.open(map, marker);
    }); 

    bounds.extend(listingLatLng);
    map.fitBounds(bounds);

    markers.push(marker);
}
而且,错误并非每次都发生。这是一个使代码崩溃的地址

法国,法兰西岛,巴黎,75006,巴黎,卡西米尔·德拉维涅街7号

我认为错误是在调用FitBounds时引起的。当错误发生时,地理编码返回的边界将缩小到省级


错误的原因是什么?当用户输入带有街道名称的地址时,我需要将地图缩放到街道级别。

某个地方没有定义边界

在使用displayMarker的方法或将其用作方法的参数之前,必须在displayMarker可访问的范围内定义它:

bounds=new google.maps.LatLngBounds();

边界在某个地方没有定义

在使用displayMarker的方法或将其用作方法的参数之前,必须在displayMarker可访问的范围内定义它:

bounds=new google.maps.LatLngBounds();

但为什么地理编码不返回边界呢。此外,为什么它会不时发生?您不能信任地理编码返回的边界,它们将在适用时返回,正如您在文档中看到的那样。您使用的地址将返回一个精确的点,一个街道编号,因此没有任何区域可以有任何边界。是的,地理编码返回未定义的边界。当我添加街道名称和编号时会发生这种情况,但如果我只键入France、Paris、75006就可以了。为什么即使有街道名称和编号也能找到完整地址,但却找不到边界?边界定义了一个区域,一个有街道编号的地址所在的点没有区域。你的评论对我帮助很大。我认为地理编码总是返回边界。但为什么地理编码不返回边界呢。此外,为什么它会不时发生?您不能信任地理编码返回的边界,它们将在适用时返回,正如您在文档中看到的那样。您使用的地址将返回一个精确的点,一个街道编号,因此没有任何区域可以有任何边界。是的,地理编码返回未定义的边界。当我添加街道名称和编号时会发生这种情况,但如果我只键入France、Paris、75006就可以了。为什么即使有街道名称和编号也能找到完整地址,但却找不到边界?边界定义了一个区域,一个有街道编号的地址所在的点没有区域。你的评论对我帮助很大。我认为地理编码总是返回边界。