Google Maps Bounds inaccurate

て烟熏妆下的殇ゞ 提交于 2019-12-13 00:25:27

问题


my problem is related to the way how LatLngBounds.extend() method works. I am not sure if this is a bug or not but it does not work as intended. I expect bounds to contain all points included in it. Unfortunately it works really strangely in my case. Please check this fiddle: http://jsfiddle.net/Sy5dC/4/.

var locationBBOX = [
'(42.00, -142.00) (70.00, -50.00)', //CANADA
'(47.274719, 5.864166000000068) (55.053055, 15.038886999999932)',//GERMANY
//'(40.00, 27.00) (70.00, 179.00)'//RUSSIA
];

In lines 23-27 you will find definitions of bounding boxes for 3 countries. Currently Russia is commented out and everything works like a charm. The problem begins when Russia is included in bounds - the map does not show the correct bounding box. Is there anything I can do to make it work?

Thanks!


回答1:


boundingBoxPoints does not encompass the same area as bbox does.

You may create the correct box for the bounds by using a Rectangle with the bounds-property set to bbox, and when you create Markers for all the points you will see that they are all located within this box.

Demo(the blue rectangle marks the real bounds): http://fiddle.jshell.net/doktormolle/EGDFH/show/

But I'm afraid that's not the desired result, unfortunately I have no solution at this time, also union() will not help here(it seems to be just a wrapper for extend(sw) & extend(ne) ).



来源:https://stackoverflow.com/questions/17569800/google-maps-bounds-inaccurate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!