无法设置经度从-180到0的LatLngBounds [英] unable to set a LatLngBounds with longitude from -180 to 0
问题描述
a = new google.maps.LatLng(-90,-180,true);
a.lng();
=> -180
b = new google.maps.LatLng(0,0,true);
c = new google.maps.LatLngBounds(a,b);
c.getSouthWest()。lng();
=> 180
问题似乎不在LatLng中,而在LatLngBounds中更多。他们是否是其他参数或其他方式来做它,因此它可以代表世界的这个季度?
测试更多的参数,只有西南经度总是设置为-180: http://jsfiddle.net/vr6ztq9z/1/
$ $ p $ $ code Math.atan(Math.sinh(Math.PI))* 180 / Math.PI;
通过这种方式,您可以找到投影的实际南北边缘 。
$ b 经度:
<-1>经度-180与180?没有。
您仍然可以识别投影的所有4个季度:
var maxLat = Math.atan(Math.sinh(Math.PI))* 180 / Math.PI;
var center = new google.maps.LatLng(0,0);
var sw = new google.maps.LatLng(-maxLat,180);
var ne = new google.maps.LatLng(maxLat,-180);
//世界的西南部分
new google.maps.LatLngBounds(sw,center);
//世界上的东南部分
new google.maps.LatLngBounds(center,sw);
等等。
When trying to set a new LatLngBounds, for the southwest quarter of the world, the SouthWest longitude is automatically set at the other side of the world, leading to an unconsistent LatLngBounds (SouthWest is more east than NorthEast)
a = new google.maps.LatLng(-90, -180, true);
a.lng();
=> -180
b = new google.maps.LatLng(0, 0, true);
c = new google.maps.LatLngBounds(a, b);
c.getSouthWest().lng();
=> 180
The problem seems not to be in the LatLng, but more in the LatLngBounds. Are they other params or other ways to do it so it can represent this quarter of the world ?
Tests with more parameters, only southwest longitude is always set to -180 : http://jsfiddle.net/vr6ztq9z/1/
Latitude:
On a Mercator projection, the maximum north latitude is not 90, but something around 85.05113. In JavaScript you can do:
Math.atan(Math.sinh(Math.PI)) * 180 / Math.PI;
This way you can find the real north and south edges of the projection.
Longitude:
What's the difference between a longitude of -180 and 180? None.
You can still identify all 4 quarters of the projection:
var maxLat = Math.atan(Math.sinh(Math.PI)) * 180 / Math.PI;
var center = new google.maps.LatLng(0, 0);
var sw = new google.maps.LatLng(-maxLat, 180);
var ne = new google.maps.LatLng(maxLat, -180);
// Southwest part of the world
new google.maps.LatLngBounds(sw, center);
// Southeast part of the world
new google.maps.LatLngBounds(center, sw);
And so on.
这篇关于无法设置经度从-180到0的LatLngBounds的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!