我正在尝试确定正在动画的标记是否在我的地图的可视区域内。如果不是,我想告诉我的地图平移到标记位置作为中心位置。我该怎么做呢?这是我的代码:
var curPoint = racePath.GetPointAtDistance(curDist);
var curZoom = self.map.zoom;
var mapBounds = new google.maps.LatLngBounds(currentCenter);
var isInBounds = mapBounds.contains(curPoint);
这是行不通的,因为 mapBounds 需要地图的西南和东北点,但我不知道如何计算它们,而不是从 mapBounds.getNorthEast() 和 mapBounds.getSouthWest() 方法中获取它们 - 记录在这里:https ://developers.google.com/maps/documentation/javascript/reference#LatLngBounds。
关于如何解决这个问题的任何想法?