Google maps 谷歌地图自定义覆盖宽度错误

Google maps 谷歌地图自定义覆盖宽度错误,google-maps,google-maps-api-3,overlay,custom-overlay,Google Maps,Google Maps Api 3,Overlay,Custom Overlay,我正在尝试为谷歌地图制作自定义覆盖图。我用这个例子。我对覆盖宽度的定义有问题 var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest()); var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast()); // Resize the image's div to fit the indicated dimensi

我正在尝试为谷歌地图制作自定义覆盖图。我用这个例子。我对覆盖宽度的定义有问题

var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast());

// Resize the image's div to fit the indicated dimensions.
var div = this.div_;
div.style.left = sw.x + 'px';
div.style.top = ne.y + 'px';
div.style.width = (ne.x - sw.x) + 'px';
div.style.height = (sw.y - ne.y) + 'px';
此代码返回的宽度小于此latlonbox覆盖的一个像素:

<LatLonBox>
<north>90.0</north>
<south>-90.0</south>
<east>180.0</east>
<west>-180.0</west>
</LatLonBox>

90
-90.0
180
-180.0

有人遇到过这个问题吗?也许有人知道解决办法。如果有任何帮助,我将不胜感激。

因为边界与本初子午线相交时似乎会发生这种情况

尝试以下方法计算宽度:

         ((ne.x - sw.x)
          +
          (((ne.x - sw.x)<0
            ||
          this.bounds_.getNorthEast().lng()
          -
          this.bounds_.getSouthWest().lng()>=360)
            ? overlayProjection.getWorldWidth()
            : 0))
((ne.x-sw.x)
+
((东北-西南)=360)
?OverlyProjection.getWorldWidth()
: 0))

演示:

哦,谢谢,这是工作!但现在我也看到了身高的问题。据我所知,在谷歌地图中,经度可以取值[-85,85],但谷歌地球kml包含值-90和90。所以,高度和顶边也是错误的。我怎样才能解决这个问题?演示:(以最小的缩放级别显示叠加)