arcgis for android 空间查询

arcgis for android 参数设置:


//查询点击地图上任意点判断是否在一个范围内(地图坐标用的大地坐标)

Point point = mapView.toMapPoint(x, y);
//投影坐标转换成经纬度
Point wgsPoint = (Point) GeometryEngine.project(point, mapView.getSpatialReference(), SpatialReference.create(4326));

QueryParameters qParameters = new QueryParameters();    //创建查询参数对象
SpatialReference sr = SpatialReference.create(4326);//设置空间参考坐标系
Envelope envelope = new Envelope(wgsPoint);//后面2个参数指的是点的高和低
qParameters.setGeometry(envelope);//设置识别位置
qParameters.setOutSpatialReference(sr);//设置输出坐标系
qParameters.setReturnGeometry(true);//指定是否返回几何对象

qParameters.setSpatialRelationship(SpatialRelationship.WITHIN);  //需要指定关系



//显示一个面的中心

Polygon polygon = (Polygon) feature.getGeometry();
Polygon poly = new Polygon();//创建多边形对象
//获取面的中心
Point pyPoint = GeometryEngine.getLabelPointForPolygon(polygon, mapView.getSpatialReference());
//经纬度转换成投影坐标
pyPoint = (Point) GeometryEngine.project(pyPoint, SpatialReference.create(4326), mapView.getSpatialReference());
for (int i = 0; i < polygon.getPointCount(); i++) {
    Point wgsPoint = polygon.getPoint(i);
    Point point = (Point) GeometryEngine.project(wgsPoint, SpatialReference.create(4326), mapView.getSpatialReference());
    if (i == 0) {
        poly.startPath(point);
    } else if (i == polygon.getPointCount() - 1) {
        poly.lineTo(poly.getPoint(0));//多边形是闭合的因此最后我们还要添加初始点的位置
    } else {
        poly.lineTo(point);
    }
}
SimpleFillSymbol symbol = new SimpleFillSymbol(Color.RED);
Graphic graphic = new Graphic(poly, symbol, feature.getAttributes());
mPoythLayer.addGraphic(graphic);


//********************************************************根据地名搜索******************************************************************* 

/**

     * 根据地名查询经纬度
     */
    private void searchPlace() {
        String address = etSearch.getText().toString().trim();
//
        LocatorFindParameters findParams = new LocatorFindParameters(address);
        // Use the centre of the current map extent as the find location point
        findParams.setLocation(mapView.getCenter(), mapView.getSpatialReference());
        // Calculate distance for find operation
        Envelope mapExtent = new Envelope();
        mapView.getExtent().queryEnvelope(mapExtent); // assume map is in metres, other units wont work, double current envelope double distance = (mapExtent != null && mapExtent.getWidth() > 0) ? mapExtent.getWidth() * 2 : 10000; findParams.setDistance(distance); findParams.setMaxLocations(2);
        // Set address spatial reference t
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值