Select to view content in your preferred language

Potential Issue setting spatial reference for JMap

2788
1
06-26-2014 01:29 PM
SachinKanaujia
Deactivated User
Hi,
I am trying to initialize a JMap with a spatial reference and extent (Valid EPSG code)

JMap jMap = new JMap(SpatialReference.create(32056), new Envelope(145027.3621, 124064.7350, 868193.2922, 1582086.7001));

I am able to launch everything perfectly and as an mpk (from ESRI sample) which gets projected correctly.

new ArcGISLocalDynamicMapServiceLayer(getPathSampleData() + "mpks/USCitiesStates.mpk");

I am able to perform various operations like Zoom and pan etc

Now I remove all layers and dispose the JMap (without close the application/jvm). Then try to do the same thing (like a projection on the fly). Since there is no setter method Spatial reference on JMap so I am creating the JMap again on click of a button and adding the mpk package as above.

The Map loads fine which correct extents. I am also able to see the map panning correctly in all directions but the zoom in and zoom out starts to fail with the following exception.

Requested an image but received content type text. Either the token used to access this server has expired or the parameters of this request are invalid.
at com.esri.core.internal.io.handler.a.a(Unknown Source)
at com.esri.core.internal.tasks.ags.j.a(Unknown Source)
at com.esri.core.internal.tasks.ags.j.execute(Unknown Source)
at com.esri.map.DynamicLayer$a.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)


When I inspect the request I find that the image size if missing from the request parameter. Why is Zoom failing which pan is working fine !!!

Regards
Sachin
0 Kudos
1 Reply
CarlosColón-Maldonado
Frequent Contributor
Requested an image but received content type text. Either the token used to access this server has expired or the parameters of this request are invalid


I believe panning does not require rendering calls to map services, but zooming does, which is the reason it's looking for imaging. In my experience, I've noticed that, when using MPK files to create and initialize map layer services, there really is no need to dispose them throughout the life (session) of the application. You may create any number of maps you want, but you should only instantiate one map service instance to load on any or all maps. I'd watch that:

1. If there is no reference to the layer service to pass on other maps when this disposing one, chances are the disposing map is also disposing it.

2. Are you using the local server? I'd use it to get the loaded map services it contains to reload the map service unto newly created maps. At least, you can use it to test if the map service is still running, or browse to the REST service to see if it's still up.

Hope this helps.
0 Kudos