【发布时间】:2023-03-24 00:33:01
【问题描述】:
我试图在 Nutiteq 下以正确的 Bounding Box 显示 Polygon,但我得到了类似的东西。
而我想要的是
我的代码如下
private void setClipBounds(Intent intent, MapView mapView) {
ArrayList<ArrayList<String>> limits = null;
if (intent.hasExtra(Constants._LIMITS)) {
limits = (ArrayList<ArrayList<String>>) intent.getSerializableExtra(Constants._LIMITS);
ArrayList<String> downLeft = limits.get(0);
ArrayList<String> upRight = limits.get(1);
double left = Double.parseDouble((String)(downLeft.get(0)));
double top = Double.parseDouble((String)(upRight.get(1)));
double right = Double.parseDouble((String)(upRight.get(0)));
double bottom = Double.parseDouble((String)(downLeft.get(1)));
MapPos downLeftPos = mapView.worldToScreen(left, bottom, 0);
MapPos rightUpPos = mapView.worldToScreen(right, top, 0);
Rect rect = new Rect(Math.round((float)downLeftPos.x), Math.round((float)rightUpPos.y), Math.round((float)rightUpPos.x), Math.round((float)downLeftPos.y));
Bounds bounds = new Bounds(left, top, right, bottom);
mapView.setBoundingBox(bounds, rect, false, false, false, 1000);
//mapView.setBoundingBox(bounds, false);
} else {
Log.i("TAG", "WmsMapActivity::setClipBounds:: NO limits!!!");
}
}
谁能告诉我,我做错了什么?
提前致谢。
【问题讨论】:
-
也许@JaakL 可以更好地解释
screenToWorld(...)的工作原理,因为我用MapPos[11.396879,48.264547] 和[11.396879,48.264546] 调用screenToWorld(...)并得到[x=- 80971.58271822847, y=289300.71649931633, z=0.0] 和 [x=-80971.58252842074, y=289300.71632176096, z=0.0] 作为关联的屏幕坐标。我正在 Nexus 9 中测试我的应用程序,因此,我应该获得范围 [0x0,1535x2047] 中的坐标,因为此设备的屏幕暗度为 1536*2048。 -
当然,如果我既没有 Action Bar 也没有向下控制栏,那么有效的 mapView 坐标是 1536*1790。
-
假设您使用的是 EPSG3857 投影,这是预期的结果 - 您正在将屏幕坐标转换为地图坐标。在 EPSG3857 的情况下,这些在 [-20037508.34, 20037508.34] 范围内
-
@MarkT 请看一下worldToScreen,不,我正在将地图坐标转换为屏幕坐标。
标签: android bounding-box boundary nutiteq