Select to view content in your preferred language

ArcGIS Android, SpatialReference is null from map and layers

2895
1
08-06-2011 02:35 PM
DanielCiobota
New Contributor
Hi all,

Hopefully in the right forum for this.  Just downloaded the Android ArcGIS API last wekk, and been playing with it.  One thing I'm trying to do but unsuccessful at the moment is get the map's spatial reference so I can set extents in degrees, no matter what spatial reference the base layer uses.

I put the code in the onStatusChanged method for both the map and layer (status=INITIALIZED) with the same result.  Here's the piece of code I'm trying to make work:

SpatialReference mercatorWeb = SpatialReference.create(102100);
Point ll = (Point)GeometryEngine.project(new Point(-96.5,40.0), mercatorWeb, map.getSpatialReference());
Point ur = (Point)GeometryEngine.project(new Point(-95.5,41.0), mercatorWeb, map.getSpatialReference());
Envelope ext = new Envelope(ll.getX(), ll.getY(), ur.getX(), ur.getY());
map.setExtent(ext);

No matter what I try, the map.getSpatialReference returns null, even if the status is INITIALIZED.  Same thing if I try a layer instead.

Any help on this much appreciated.
0 Kudos
1 Reply
DanielCiobota
New Contributor
Well, to answer my own question, the spatial reference wasn't null, just the description of it.  To make the extents work in degrees, all I had to change was the wkid for the mercatorWeb spatial reference to a geographic spatial reference (4326), since the units for projected spatial references are usually in meters, and geographic references are in degrees. 

Hope that helps someone as confused as me.  😉
0 Kudos