Nutiteq下的SetBoundings无法正常工作

时间:2014-11-07 10:41:33

标签: android bounding-box boundary nutiteq

我试图在正确的Polygon下在Nutiteq下显示Bounding Box,但我得到类似的内容。 Sight of a field wrong bounded

我想要的是

Sight of that field properly bounded

我的代码如下

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!!!");   
    }

}

有谁能说我,我做错了什么?

提前致谢。

1 个答案:

答案 0 :(得分:1)

你使用了错误的rect参数 - 在你的情况下它应该包含你的视图尺寸(你不需要调用worldToScreen,worldToScreen根据当前的摄像机参数计算屏幕坐标)。