Invalid SpatialReference

3354
3
10-29-2012 01:49 AM
DidarBultanov
New Contributor II
Hello, I'm just starting to work with android sdk
I do everything by example helloworld
XML
[HTML]<com.esri.android.map.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
initExtent = "-25256.2258543979 -17337.2451528132 28560.1317783174 13883.6506223117">
</com.esri.android.map.MapView>[/HTML]
Java
[HTML]public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  map = (MapView)findViewById(R.id.map);
  // Add dynamic layer to MapView
   basemap = new ArcGISTiledMapServiceLayer("http://myserver:8000/ArcGIS/rest/services/MyServices/MapServer");
  map.addLayer(basemap);

}
[/HTML]
Log:
10-29 11:15:50.520: E/ArcGIS(700): url =http://myserver:8000/ArcGIS/rest/services/MyServices/MapServer
10-29 11:15:50.520: E/ArcGIS(700): java.lang.RuntimeException: Invalid SpatialReference.
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.core.geometry.SpatialReference.nativeGetWKID(Native Method)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.core.geometry.SpatialReference.create(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.core.geometry.SpatialReference.fromJson(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.core.internal.c.g.a(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.core.internal.a.a.n.b(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.android.map.ags.ArcGISTiledMapServiceLayer.initLayer(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at com.esri.android.map.ags.ArcGISTiledMapServiceLayer$1.run(Unknown Source)
10-29 11:15:50.520: E/ArcGIS(700):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
10-29 11:15:50.520: E/ArcGIS(700):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-29 11:15:50.520: E/ArcGIS(700):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-29 11:15:50.520: E/ArcGIS(700):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-29 11:15:50.520: E/ArcGIS(700):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-29 11:15:50.520: E/ArcGIS(700):  at java.lang.Thread.run(Thread.java:856)

My service is cached and running
where and how to to specify parameter SpatialReference
[ATTACH=CONFIG]18795[/ATTACH]
0 Kudos
3 Replies
DanO_Neill
Occasional Contributor III
Take out the initExtent parameter from your layout xml file. You are using you own map service which is in a different spatial reference than the service provided in the HelloWorld sample. If you still want to set the initial extent in your layout xml file, then adjust the coordinates to the spatial reference of your map service.
0 Kudos
DidarBultanov
New Contributor II
Take out the   initExtent parameter from your layout xml file. You are using you own map service which is in a different spatial reference than the service provided in the HelloWorld sample. If you still want to set the initial extent in your layout xml file, then adjust the coordinates to the spatial reference of your map service.


please can show an sample
//import android.R.string;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;


import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.SpatialReference;




public class CityActivity extends Activity {
MapView mv = null;
SpatialReference wgs84 = SpatialReference.create(4326);
Context content;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Envelope envelope=new Envelope(-25256, -17337, 28560, 13883);
mv=new MapView(content, wgs84, envelope);
ArcGISTiledMapServiceLayer Tservice=new ArcGISTiledMapServiceLayer("http://myserver:8000/ArcGIS/rest/services/myservices/MapServer");
//mv.setExtent(envelope);
mv.addLayer(Tservice);
// setContentView(mv);

}
@Override
does not start((
Thanks
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
this might be because your data is not in WKID 4326.  It's in a modified Spatial Reference.  That's ok.  You can define that in your code. 
I can't see it all in the screen shot so you'll have to finish it.  Just copy/paste your Spatial Reference from your REST endpoint into your codeblock..

SpatialReference wgs84 = SpatialReference.create("GEOGCS['GCS_WGS_1984',DATUM[.........]]);

You'll have to finish the Spatial Reference text.  I can't see it all, and I don't feel like typing it.  You get my point 😉

Hope this helps.
0 Kudos