正常來說通過接口獲取這樣的多面數(shù)據(jù):
"geom":"SRID=4326;MULTIPOLYGON(((112.42895654300003 22.552396602000044,112.42907274700008 22.55247649300003,112.42915152800003 22.552530657000034,112.42921560100001 22.552533587000028,112.42920648400002 22.55248800800007,112.4292030580001 22.552453743000058,112.4292030580001 22.55242290500007,112.42919620400005 22.55238864000006,112.42918592400008 22.55236465400003,112.42917221800008 22.552330389000076,112.42915851100008 22.552306403000046,112.42914480500008 22.55228241800006)))“
我們需要對其進(jìn)行轉(zhuǎn)為對應(yīng)的多面對象或者是幾何體Geometry,這樣就可以直接GraphicLayer.addGraphic(Geometry)方法來顯示了名斟;但需要非常注意的一點(diǎn)是如果不是自己組建Polygon來進(jìn)行顯示的話耿芹,而已直接通過這樣的生成jsonParser = jsonFactory.createJsonParser(geoJson);
MapGeometry mapGeometry = GeometryEngine.jsonToGeometry(jsonParser);
Geometry geometry = mapGeometry.getGeometry();
那就必須先把返回的經(jīng)緯度通過GeometryEngine.project()來轉(zhuǎn)換為投影坐標(biāo)才行 ,
那就必須先把返回的經(jīng)緯度通過GeometryEngine.project()來轉(zhuǎn)換為投影坐標(biāo)才行 ,
那就必須先把返回的經(jīng)緯度通過GeometryEngine.project()來轉(zhuǎn)換為投影坐標(biāo)才行 ,
重要的事說三遍.
附上相關(guān)坐標(biāo)轉(zhuǎn)換
SpatialReference mSR4326 = SpatialReference.create(4326);
SpatialReference mSR3857 = SpatialReference.create(3857);
1. 屏幕坐標(biāo)轉(zhuǎn)換成投影坐標(biāo)
@Override
public boolean onSingleTap(MotionEvent point) {
SpatialReference sr = map.getSpatialReference();
Point dp = map.toMapPoint(point.getX(), point.getY());
}
2. 投影坐標(biāo)轉(zhuǎn)換成經(jīng)緯度
Point wgsPoint = (Point) GeometryEngine.project(dp?,map.getSpatialReference(),mSR3857);
3、經(jīng)緯度轉(zhuǎn)換成投影坐標(biāo)
Point mapPoint = (Point) GeometryEngine.project(wgsPoint ,mSR4326,map.getSpatialReference());
4浑槽、投影坐標(biāo)轉(zhuǎn)換成屏幕坐標(biāo)
Point screenPoint = map.toScreenPoint(mapPoint);