0
Google 로컬 검색을 사용하여 약간의 지오 코딩을하고 있으며 페이지에서 Google지도 api v3 객체의 뷰포트를 설정할 수 있어야합니다.Google지도의 뷰포트를 계산 하시겠습니까?
Google 로컬 검색에서 우편 번호 나 거리와 마찬가지로 좋은 뷰포트를 반환했지만 바의 이름을 입력하면 괜찮습니다. 로컬 검색에서 많은 일치 항목을 찾았지만 가장 좋은 결과를 반환했기 때문에 반환 된 뷰포트는 매우 큰 것으로 추정됩니다.
나는이 경우 내 자신의 뷰포트를 계산하고 싶습니다 다음과 같은 방식으로 그렇게하고: 문제는 내가 어떤 유효한 JSON을 얻을 수 있지만, 구글 맵 그래서 내가 볼 수있는 권리 축소입니다
result.Centre = new LatLon(double.Parse(lat),double.Parse(lon));
result.Span = new LatLon(0.006295d, 0.008407d);
string viewport = "{{\"center\":{{\"lat\":\"{0}\",\"lng\":\"{1}\"}},\"span\":{{\"lat\":\"{2}\",\"lng\":\"{3}\"}},\"sw\":{{\"lat\":\"{4}\",\"lng\":\"{5}\"}},\"ne\":{{\"lat\":\"{6}\",\"lng\":\"{7}\"}}}}";
//Calculate the south west by taking half the span and adding it to the centre
double swLat = result.Centre.Latitude + (result.Span.Latitude/2);
double swLon = result.Centre.Longitude + (result.Span.Longitude/2);
//and northeast corners by taking half the span and subtracting from the centre
double neLat = result.Centre.Latitude - (result.Span.Latitude/2);
double neLon = result.Centre.Longitude - (result.Span.Longitude/2);
//Fingers crossed :)
result.ViewPortJSON = string.Format(viewport, result.Centre.Latitude, result.Centre.Longitude,result.Span.Latitude, result.Span.Longitude, swLat, swLon,neLat, neLon);
전 세계. 구글이 나에게 뷰포트를 주었던 것처럼 프론트 엔드에서 동일한 코드가 사용되고있다. 그래서 나는 무슨 일이 일어나고 있는지 이해하지 못한다.
아이디어가 있으십니까? 계산이 잘못 됐어? 동일한 효과로 전체 범위 (예 : 이미 반경이라고 가정)로 시도했습니다.
미리 감사드립니다.
네를! doh, 나는 위도와 경도가 아닌 X와 Y의 관점에서 생각하고있었습니다. 감사 :-) –