Getting proper map boundaries

谁都会走 提交于 2019-12-24 05:37:36

问题


I use the simple:

var ne = gMap.getBounds().getNorthEast(),sw = gMap.getBounds().getSouthWest();

to get the lat long of the boundaries of a map

It works fine when the map is like this:

But when the map is like this:

The North-East lat long comes as something like 63.821287740550275, -179.73632762500006. Which creates a problem because this lat long is almost same as the South-West resulting in no-area between them.

Is there a way to get the desired values, something like a maximum value if it crosses the line.


回答1:


If you refer to this question: Get non-wrapping map bounds in Google Maps API V3

You'll see that as you have stated the map obviously wraps on the date line, so that as you zoom out you don't end up with blank areas at the edges and so that you scroll off the edge of china and hit America etc.

If you examine the answers you will see that you need to check for this wrap and go from there. And interesting question that I had never really considered!



来源:https://stackoverflow.com/questions/21454466/getting-proper-map-boundaries

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