Hello everyone,
I am developing arcgis android project. But I think is there any way to specify other SpatialReference ? I mean I want to set my layers spatialreference to WKID : 4326..I looked examples but i didn't see any solution for me.
I need your ideas.. Thanks in advices ..
Do you mean you want to project your data to WGS84? Or are you simply trying to specify that the layer's data is WGS84?
You can create a WGS84 SpatialReference using the static method create() on that class as follows:
SpatialReference wgs84 = SpatialReference.create(SpatialReference.WKID_WGS84)
(see SpatialReference | ArcGIS Android 10.2.4 API )
And you can project geometries from one SpatialReference to another using GeometryEngine's static methods for project(...), which allow you either to specify a geotransformation explicitly (if needed) or to leave the choice up to ArcGIS.
(see GeometryEngine | ArcGIS Android 10.2.4 API )
If you want to effectively have your layer (in XYZ SpatialReference) re-project on the fly to WGS84, then I'd suggest you do that as part of data / service preparation, rather than trying to code a solution in Android.
If, on the other hand, you have no control over the data / service, or there are other sound reasons why you need to re-project on the fly, then your solution will depend on the type and nature of the data you're bringing in.
If you are enabling your user to add their own raster data at runtime, then you could use the project method of FileRasterSource, although you'd want to have some knowledge of the SpatialReference(s) in which the user-supplied data was coming.
(see FileRasterSource | ArcGIS Android 10.2.4 API )
If it's raster in the form of a TiledLayer, then you don't want to be changing the SpatialReference, or you could experience tile alignment issues.
If it's a DynamicLayer, then this class has a protected field supportedSRs, which should presumably give an indication of whether the service will support re-projection to WGS84 (presumably, if it does, and the MapView's SpatialReference is WGS84, then the MapView will handle the renewed call to the service internally... someone else may be in a better position to clarify here, or you could simply test it out??). You'd need to subclass in order to access the protected field, however (or perhaps rely on the MapView giving an error if WGS84 is not supported by the layer??)
(see DynamicLayer | ArcGIS Android 10.2.4 API )
If it's a FeatureLayer, then how you change the layer's spatial reference depends on its data source, as described in the doc (under Class Overview):
(see FeatureLayer | ArcGIS Android 10.2.4 API )
Hope one of those covers your situation?!