Giuseppe,
There is no example that I am aware of. Adding a raster to a service is has nothing to do with flex or the viewer app and has everything to do with publishing services using ArcGIS Server. Just add the raster to your MXD and then publish the map service and when you add the map service as a dynamic layer it will just be part of that map service layer.
Hi Robert,thank for your reply but I think that I can add a raster dynamically by code. When you publish a mapserver you can set a workspaces for dynamic layer (service editor-->capabilities-->mapping).[ATTACH=CONFIG]34727[/ATTACH]When you add a workspaces you can chose "raster workspace" and select a folder that contain your raster.Now I would like add the raster to my map using the workspace name + raster file name.I'm developed similar functionality for a feature class stored within a database workspace and file geodatabase too. You can see my code:
private function addDynamicLayerToMap(simpleRenderer:SimpleRenderer):void {
var geoDbFileId:String = getGeoDbFileIdFromUrl(); // for example: geoDbFileId = "edifici"
var agsDynamicUrl:String = "http://<AGS server>/arcgis/rest/services/test/MapServer/dynamicLayer";
var tableDataSource:TableDataSource = new TableDataSource();
tableDataSource.workspaceId = "DBMasterDynamicWorkspaceID"; // where "DBMasterDynamicWorkspaceID" is dynamic workspace (type = Database) defined in AGS
tableDataSource.dataSourceName = geoDbFileId;
var layerDataSource:LayerDataSource = new LayerDataSource();
layerDataSource.dataSource = tableDataSource;
var featureLayer:FeatureLayer = new FeatureLayer(agsDynamicUrl, null, agsSecurityToken);
featureLayer.renderer = simpleRenderer;
featureLayer.source = layerDataSource;
featureLayer.name = nameLayer;
map.addLayer(featureLayer);
}
I'm trying with raster:
var rasterDataSource:RasterDataSource = new RasterDataSource();
rasterDataSource.workspaceId = workspaceName;
rasterDataSource.dataSourceName = geoDbFileId;
layerDataSource.dataSource = rasterDataSource;
but I can't see the raster on map.links ArcGIS Help 10.1:- ArcGIS API for FLEX - Dynamic workspace example- About dynamic layer - Supported functionality in map services where you can read:Dynamic layers are supported by REST, COM, and non-Esri SOAP clients. Additionally, dynamic layers only support feature layers and raster layers from the following data sources:
ArcSDE geodatabase
File geodatabase
Shapefile
Raster
Query layers (from ArcSDE enterprise geodatabase or non-SDE enterprise database only)RegardsGiuseppe