1

我是 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);

我知道纬度和经度都是正确的,但由于某种原因,我的观点在大西洋的某个地方得到了体现……

4

1 回答 1

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]
于 2013-06-07T07:05:25.590 回答