Reputation: 1191
I am new to arcgis, and I would like to do a simple thing, yet I can't understand why it does not behave as expected. I am trying to add a point on my mapView. It is added, but in the wrong place.
// 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);
I know that latitude and longitude are both correct, but my point gets shown somewhere in the Atlantic for some reason...
Upvotes: 1
Views: 808
Reputation: 299
I think you're on WGS84 and you need to use Web Mercator.
Here is a similar post online.
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]
Upvotes: 3