以下情况:
碰撞复选框与标记不是问题,但我无法使其工作以相应地移动地图。
这就是我的尝试:
google.maps.event.addListenerOnce($scope.map, "projection_changed", function() {
$scope.projection = $scope.map.getProjection();
});
var sidebar = document.getElementById('sidebar');
var rect = sidebar.getBoundingClientRect();
var marker = $scope.mainmarker.getPosition();
marker = $scope.projection.fromLatLngToPoint(marker);
marker.x = rect.left / 2;
marker = $scope.projection.fromPointToLatLng(marker);
$scope.map.setCenter(marker);
但是从我看到的地图移动太远了。
答案 0 :(得分:0)
我解决了这个对我有用的解决方案:
if (underneath === true) {
var marker = $scope.mainmarker.getPosition();
var pixelpoint = $scope.projection.fromLatLngToPoint(point);
pixelpoint.x += 250 / Math.pow(2, $scope.map.getZoom());
point = $scope.projection.fromPointToLatLng(pixelpoint);
$scope.map.setCenter(point);
}