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