0
API가 묻는 Google지도의 네 구석을 얻으려고합니다.Google지도로지도 모서리 좌표 가져 오기 - javascript api
swLat swLng neLat neLng
나는 다음과 같은 코드를 가지고 있지만이는 반환 객체이 그도를 묻는 것입니다 확실하지 메신저. 이 pair up (일단 그들이 correctyl을 돌려 준다) NE ->? 감사합니다
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
google.maps.event.addListenerOnce(map, 'bounds_changed', function() {
var rectangle = new google.maps.Rectangle({
bounds: map.getBounds()
})
var bounds = rectangle.getBounds();
var NE = bounds.getNorthEast();
var NEmark = new google.maps.Marker({
map: map,
position: NE,
title: "NE"
});
var SW = bounds.getSouthWest();
var SWmark = new google.maps.Marker({
map: map,
position: SW,
title: "SW"
});
// North West
var NW = new google.maps.LatLng(NE.lat(), SW.lng());
var NWmark = new google.maps.Marker({
map: map,
position: NW,
title: "NW"
});
// South East
var SE = new google.maps.LatLng(SW.lat(), NE.lng());
var SEmark = new google.maps.Marker({
map: map,
position: SE,
title: "SE"
});
$scope.NE = NE
$scope.NW = NW
$scope.SW = SW
$scope.SE = SE
var polygon = new google.maps.Polygon({
map: map,
paths: [
[NE, NW, SW, SE]
]
});
map.setZoom(map.getZoom() - 1);
});
console.log("SE" + $scope.SE) //all undefined
console.log("NW" + $scope.NW)
console.log("SW" + $scope.SW)
console.log("NE" + $scope.NE)