Add Raster With no Basemap

3193
4
03-27-2014 03:52 AM
MichaelKnight
New Contributor II
Hi Guys,

I have been looking at the 'Add Raster' sample and would like to be able to manually add a raster dataset in isolation with no other layers on the map.

When I try doing this the map just displays white. Is this something that should be supported?

All I have done to test this out is take the LocalRasterApp example and removed the lines where the basemap layer is added.

//ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");

//jMap.getLayers().add(tiledLayer);

If I do this when I add a raster dataset it shows the issue.

Thanks,
Mike
0 Kudos
4 Replies
MarkBaird
Esri Regular Contributor
It's possible that the map is not viewing the area of your raster.

Using the data in the sample can you see the it if you do the following after adding the layer?

map.setExtent(new Envelope(-19856505, -8827900, 18574809, 16806021));

Mark
0 Kudos
MichaelKnight
New Contributor II
I have tried this and it does not make a difference. One interesting observation is that if I try adding the data in reverse order (raster then tiled basemap) I get the following error

java.lang.RuntimeException: Tiled layer has different spatial reference from the map.
at com.esri.map.JMap$b.layerInitializeComplete(Unknown Source)
at com.esri.map.Layer.fireLayerCreateCompleteEvent(Unknown Source)
at com.esri.map.ArcGISTiledMapServiceLayer$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

However I am still only looking to add a raster in isolation but wondered if this would help isolate the issue. I am using the usa_raster for my testing.

Thanks,
Mike
0 Kudos
MarkBaird
Esri Regular Contributor
What your error message shows is that the local server is reprojecting your image from a different spatial reference when you open the tiled layer first.  A tiled layer will not reproject hence the error.

Anyway it's worth starting by saying that your workflow of opening up the raster image on it's own is supported and I can get it to work against 10.2 so we just need to look at what is happening.

In your LayerInitializedCompleteListener, what is the spatial reference of your map?  My map is coming out as 4326 so my set Extent method is working fine.  I'm however wondering if your blank mpk has been changed so the SR is WGS84.  In which case you need to be setting the extent of your map using WGS84 coordinates (lat/long)

Let me know how you get on.


Mark
0 Kudos
CarlosColón-Maldonado
Occasional Contributor III
I have tried this and it does not make a difference.


I'd set the full extent of the map as that of the world:

[ATTACH=CONFIG]32618[/ATTACH]

This will ensure you're able to zoom/pan to where the raster may be projected.

Hope this helps.
0 Kudos