Arcgis android,没有显示正确的坐标

时间:2013-06-07 06:56:20

标签: android arcgis

我是arcgis的新手,我想做一件简单的事情,但我无法理解为什么它没有像预期的那样表现。我想在mapView上添加一个点。它被添加,但在错误的地方。

// I have longitude and latitude saved as strings
// x = 53.230
// y = 20.398
Point result = new Point(Float.parseFloat(x),Float.parseFloat(y));

  Point mapPoint = (Point) GeometryEngine.project(Double.parseDouble(x), Double.parseDouble(y), SpatialReference.create(4326));

      Geometry resultLocGeom = mapPoint; 
      Geometry resultLocGeom = result; // using mapPoint or result, both gets placed in same place.

  SimpleMarkerSymbol resultSymbol = new SimpleMarkerSymbol(
    Color.BLACK, 20, SimpleMarkerSymbol.STYLE.CROSS);

  Graphic resultLocation = new Graphic(resultLocGeom,
    resultSymbol);

  locationLayer.addGraphic(resultLocation);

  TextSymbol resultAddress = new TextSymbol(12, list2.get(i)[3], Color.BLACK);

  resultAddress.setOffsetX(10);

  resultAddress.setOffsetY(50);

  Graphic resultText = new Graphic(resultLocGeom, resultAddress);

  locationLayer.addGraphic(resultText);

我知道纬度和经度都是正确的,但出于某种原因,我的观点会在大西洋的某处显示出来......

1 个答案:

答案 0 :(得分:3)

我认为您使用的是WGS84,需要使用Web Mercator。

这是一篇类似的在线帖子。

http://forums.arcgis.com/threads/53852-FeatureLayer-does-not-accept-WGS84-(-WKID-4326-)

fs=FeatureSet

[PHP]                 
$.each( fs.features, function(k, v){
    point=new esri.geometry.Point( v.geometry.x, v.geometry.y, new esri.SpatialReference({ wkid: 4326 }));
    point_merc = esri.geometry.geographicToWebMercator(point);

    v.geometry.x=point_merc.x;
    v.geometry.y=point_merc.y;                   
});
[/PHP]