Raster Layer: Change FilePath

201
0
06-30-2019 07:13 AM
LiglioCavalcante
New Contributor

Hi,

 

I want to dinamically change the file displayed in a raster layer, using javascript API .

How can I do that ?

I can point to the sublayer, but I can not see this property to change.

 

import MapView from 'esri/views/MapView'
import EsriMap from 'esri/Map'
import MapImageLayer from 'esri/layers/MapImageLayer'


let mapCtrl
let objMap
let objLayer

const createMap = (state, action) => {
objLayer = new MapImageLayer({ url:'http://rjgis01.reger.ons:6080/arcgis/rest/services/Mapa_GIS/MapServer' })

objMap = new EsriMap({
basemap: 'gray',
layers: [objLayer]
})

mapCtrl = new MapView({
container: action.domNode,
map: objMap,
zoom:5,
center:[-58.13, -14.30]
})


return { ...state, mapCtrl }
}

const filterMap = (state, action) => {

objLayer.when(function() {
objLayer.sublayers.map(function(grouplayers) {
grouplayers.sublayers.map(function(sublayer){
if (sublayer.title.indexOf('Raster Prob') > -1)
{
console.log('sublayer.source.type = ' + sublayer.source.type)
console.log('sublayer.datasource = ' + sublayer.datasource)
sublayer.visible = true
}
})
})
})

return state
}

const map = (state = INITIAL_STATE, action) => {
switch (action.type) {
case 'CREATE_MAP':
return createMap(state, action)
case 'FILTER_MAP':
return filterMap(state, action)
default:
return state
}
}

export default map

0 Kudos
0 Replies