Solved! Go to Solution.
You can detect the spatial reference before you add the tpk to the map.
final ArcGISLocalTiledLayer tl = new ArcGISLocalTiledLayer("C:\\Data\\forum\\Canada_myScheme.tpk");
tl.initializeAsync();
tl.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {
@Override
public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
System.out.println("init" + tl.getDefaultSpatialReference().getText());
//add it to the map if you are happy with the spatial reference
map.getLayers().add(tl);
}
});
@Override public void layerInitializeComplete(LayerInitializeCompleteEvent e) { count++; ArcGISLocalTiledLayer layer = (ArcGISLocalTiledLayer) e.getLayer(); if (layer.getStatus() == LayerStatus.INITIALIZED) { System.out.println(String.format(count + "-LayerInitializeCompleteEvent- Layer '%s' is initialized !", layer.getName())); if (layer.getSpatialReference() != null) { System.out.println(count + " layer spatial ref : " + layer.getSpatialReference().getText()); } else { System.out.println(count + " layer spatial ref IS NULL !!!"); } //add it to the map if you are happy with the spatial reference map.getLayers().add(layer); } else { System.out.println(String.format(count + "-LayerInitializeCompleteEvent- ERROR: Layer '%s' has status : '%s'", layer.getName(), layer.getStatus())); } }
Java version : 1.7.0_07 (Oracle Corporation) x86 Rendering engine : DirectX 1-LayerInitializeCompleteEvent- Layer 'C:\temp\Canada.tpk' is initialized ! 1 layer spatial ref IS NULL !!! -MapEventListenerAdapter- Map is ready ! 2-LayerInitializeCompleteEvent- Layer 'C:\temp\Canada_cities.tpk' is initialized ! 2 layer spatial ref IS NULL !!!
It's also worth noting that there is a cost (sometimes quite significant) to reprojecting spatial data on the fly. It will always take longer to render data which is not in the same spatial reference.
I do however think that it's acceptable to have a web Mercator basemap and project data in a wgs84 spatial reference. This is not a costly process.
Is it possible to overlap 2 Tiled Packages which are in different Spatial Reference ?
It's not possible, no. You can't stack tiled layers with a difference spatial reference.
The first layer added to the map will define the map's spatial reference. Subsequent layers, except for tiled layers, will be re-projected to this spatial reference. Tiled layers won't be displayed if the tiled layer's spatial reference doesn't match the map's spatial reference (and hence the first layer's spatial reference).
The code you posted earlier showed you were using the getSpatialReference method.
I suggusted trying the getDefaultSpatialReference method. Is this not working for you?