Spatial Reference of MapView

5992
7
02-05-2015 01:49 PM
GuillaumeLanglois2
New Contributor

Hi,

I've just started to use the ArcGIS Android SDK yesterday and I'm currently working with local tiled package layers.

My local tpk file was created in ArcGIS for Desktop v10.2.2 from shapefiles with the NAD 1983 MTM 9 projection.

However the spatial reference of my MapView is 102100 (WGS_1984_Web_Mercator_Auxiliary_Sphere). I expected NAD 1983 MTM 9.

Is there a way to change it?  I tried the MapView(Context context, SpatialReference spatialreference, Envelope extent) constructor but all I got is a blank screen.

Thanks!

0 Kudos
7 Replies
TeroRönkkö
Occasional Contributor

I just started working on Android runtime and am fighting over same thing except that I am still using public base maps with local runtime geodatabase.

As far as I understand it, changing the Mapview spatialreference is impossible after it has been set. And it is set as soon as you add first layer. And in fact the first layer comes from the Mapview layout description if you set it:

mapoptions.MapType="Topo"

So if you have that in your layout, spatialreference will be what ever that layer has. And probably is WGS84.

And in case you are using local geodatabase for featuredrawing, it will be impossible to make them show if they are not in the same system.

On the fly reprojection would be nice.

SalihYalcin
New Contributor III

Hello Tero,

I've been using Esri Android SDK for my app development. Can you give any idea how can i use on the fly porjection on map ?

0 Kudos
TeroRönkkö
Occasional Contributor

Are you trying to project tilelayers/basemaps or features from some source?

0 Kudos
SalihYalcin
New Contributor III

Let me explain my issue.

I have added ArcGISDynamicMapServiceLayer in my project. We use our custom coordinate system;

Our coordinate system parameters;

----LogCat give this for coordinate system---

[mWKID=0, mWKT=PROJCS["ITRF_96_UTM_Zone_35N",GEOGCS["GCS_GRS_1980",DATUM["D_ITRF_1996",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",30.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]], mUnit=null, mTolerance=NaN, mGCS=null]

----LogCat give this for coordinate system---

Our coordinates are like this ;

X: 394300.42, Y:4537259.38

I used LocatianDisplayManager for "go my location" property of my app. When i click to the button, app give me coordinates like 28.4124 , 40.9985 (geographical coordinates). I should convert them to my coordinate system. I tried converting but app crashed when i use mapview.getspatialreference.

I think i should use on the fly projection but i dont understand how can i use this.

I hope i explained.

Thanks.

0 Kudos
SalihYalcin
New Contributor III

I've solved by myself.

In order to use my maps coordinate I make MapView.getSpatialReference

0 Kudos
TeroRönkkö
Occasional Contributor

You can change the MapView spatialreference by loading online WMS service with specific spatial reference:

mMapView.addLayer(newcom.esri.android.map.ogc.WMSLayer(

                "http://someserver?", SpatialReference.create(1234) ));

ArcGISLocalTiledLayer doesn't have such functionality so your only option is to load it first and hope for the best.

By default loading wmslayer puts it to WGS84 spatialreference so this might be bug or fault in the API if it doesn't work for TPK. (Have to try this myself later)

GuillaumeLanglois2
New Contributor

Thank you Tero for your help. Unfortunately my MapView declaration in XML has no mapOptions.Maptype attribute. The only loaded layer is a tpk. Regarding for the WMS, I want to work completly offline for now. I'll let you know how it progresses next week.

0 Kudos