2013-04-12 2 views
2

만 알면 북서쪽과 남동쪽 점을 먼저 알아야 LatLngbounds를 먼저 구성 할 수 있습니다.Google지도 사각형을 그리는 방법 Google지도에 사각형을 그릴 때 크기와 동북 점

내 경우에는 특정 북서쪽 지점과 크기 (100 미터 너비 및 100 미터 높이)의 직사각형을 그려야합니다. 나는 가장 중요한 점을 모른다.

나는 기하학과 지질학을 두려워합니다. 나는 남동쪽이 몇몇 포물에서 파생 될 수 있다는 것을 압니다. 그냥 API가 있는지 또는 쉽게 할 수 있는지 알고 싶습니까?

답변

5
을 포함해야합니다

다음
// Given the LatLng of a northwest corner, and the number of meters to 
// measure east and south, return the LatLngBounds for that rectangle 
function makeBounds(nw, metersEast, metersSouth) { 
    var ne = google.maps.geometry.spherical.computeOffset(
     nw, metersEast, 90 
    ); 
    var sw = google.maps.geometry.spherical.computeOffset(
     nw, metersSouth, 180 
    ); 
    return new google.maps.LatLngBounds(sw, ne); 
} 

는입니다 :

이 같은 기능을 쓸 수 있습니다.

+0

이 테스트되었습니다. IT가 당연히 작동합니다. – GingerJim

1

도형 라이브러리에서 computeOffset을 참조하십시오.

computeOffset (에서 : LatLng를 거리 : 번호, 제목 : 번호, 반경 : 수) (테스트하지) 같은

뭔가 :

var NorthEast = google.maps.geometry.spherical.computeOffset(NorthWest, width, 90); 
var SouthWest = google.maps.geometry.spherical.computeOffset(NorthWest, height, 180); 
var SouthEast = google.maps.LatLng(SouthWest.lat(),NorthEast.lng()); 

하면 geometry library

관련 문제