Google 地图自动完成获取 LatLngBounds?

Google map autocomplete get LatLngBound?

如何在自动完成的地方获取 latlngbound?

为了获取纬度,我使用以下代码

var place = places.getPlace();
var latitude = place.geometry.location.lat();

但是当我尝试按照代码获取 latlngbounds 时它不起作用

// northeast is undefined
var latlngbounds = place.geometry.bounds.northeast.lat();

// undefined
var latlngbounds = place.geometry.bounds;

PlaceGeometry 还包括一个建议的视口,它是一个 google.maps.LatLngBounds 对象。 (它的名字是视口,而不是边界)

Properties  Type    Description
location    LatLng  The Place's position.
viewport    LatLngBounds    The preferred viewport when displaying this Place on a map. This property will be null if the preferred viewport for the Place is not known.
var place = places.getPlace();
var latitude = place.geometry.location.lat();
var bounds = place.geometry.viewport;