地图查询结果为空

0 投票

查询结果为空,找不到出错原因。代码如下,距离查询的距离distance具体是什么单位呢?传入的点的坐标是经纬度即可还是需要转成坐标系呢?fp.name取的是.../maps/POIxnixi_Sheet1_1@text尾部的图层名吗?

package dream.team.iservertest;

import android.content.res.Configuration;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.supermap.android.commons.EventStatus;
import com.supermap.android.data.GetFeaturesResult;
import com.supermap.android.maps.LayerView;
import com.supermap.android.maps.MapView;
import com.supermap.android.maps.query.FilterParameter;
import com.supermap.android.maps.query.QueryByDistanceParameters;
import com.supermap.android.maps.query.QueryByDistanceService;
import com.supermap.android.maps.query.QueryEventListener;
import com.supermap.android.maps.query.QueryResult;
import com.supermap.services.components.commontypes.Geometry;
import com.supermap.services.components.commontypes.GeometryType;

public class MainActivity extends AppCompatActivity {

    // SuperMap iServer提供的地图采用固定地址传递
    private static final String DEFAULT_URL = "http://localhost:8090/iserver/services/map-baidu/rest/maps/normal";
    private static final String QuaryUrl = "http://localhost:8090/iserver/services/map-POIxinbu2/rest/maps/POIxnixi_Sheet1_1@text";
    private double distancePointX = 114.3;
    private double distancePointY = 30.5;
    private int count;
    TextView text;
    protected MapView mapView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //创建地图窗口
        text = (TextView) this.findViewById(R.id.Testext);
        mapView = (MapView) this.findViewById(R.id.mapview);
        //创建地图图层,并指向iServer提供的地图服务
        LayerView layerView = new LayerView(this);
        layerView.setURL(DEFAULT_URL);
        //设置地图缩放
        mapView.setBuiltInZoomControls(true);
        //加载地图图层
        mapView.addLayer(layerView);
        distanceQuery();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    private void distanceQuery() {
        QueryByDistanceParameters p = new QueryByDistanceParameters();
        p.distance =30;// 必设,查询距离,单位为地理单位
        Geometry g = new Geometry();
        // 构建点地物,必设
        g.type = GeometryType.POINT;
        g.points = new com.supermap.services.components.commontypes.Point2D[]{new com.supermap.services.components.commontypes.Point2D(distancePointX, distancePointY)};// iserver端的Point2D
        g.parts = new int[]{1};//
        p.geometry = g;
        // p.expectCount = 2;
        FilterParameter fp = new FilterParameter();
        // fp.attributeFilter = "SMID > 0";
        fp.name = "POIxnixi_Sheet1_1@text";// 必设,图层名称(图层名称格式:数据集名称@数据源别名)
        p.filterParameters = new FilterParameter[]{fp};
        QueryByDistanceService qs = new QueryByDistanceService(QuaryUrl);
        qs.process(p, new MyQueryEventListener());
        text.setText(count+"");
    }

    public class MyQueryEventListener extends QueryEventListener {

        /**
         * <p>
         * 查询完成回调该接口,用户根据需要处理结果sourceObject
         * </p>
         *
         * @param sourceObject 查询结果
         * @param status       查询结果状态
         */
        @Override
        public void onQueryStatusChanged(Object sourceObject, EventStatus status) {
            //Message msg = new Message();
            if (sourceObject instanceof QueryResult) {
                QueryResult qr = (QueryResult) sourceObject;
                if(qr==null)
                    count=0;
                else
                    count=qr.quertyResultInfo.totalCount;
                }
            }


        }
    }

以及logcat如下:

9月 13, 2017 分类:  253次浏览 | 用户: rubbishct (6 分)
重新分类 9月 13, 2017 用户:李熙y

1个回答

0 投票
(1)iServer发布的rest地图服务在iclient for Android上加载的url不能用localhost,应该用对应的ip,否则无法打开在线数据;

(2)距离查询时设置的查询半径的单位和查询的数据图层对应的数据集的单位一致,所以如果查询的数据集是地理坐标系,设置半径的单位为度,所以需要合理半径值;

(3)如果不是很清楚可以参考解压包下samplecode中的对应范例。
9月 18, 2017 用户: 王国新 名扬四海 (1,932 分)
...