Shared Samples

WebGIS enables powerful geospatial web applications and services that securely share your organization’s rich geospatial data, and provides tools to deeply examine spatial data and create value added products, on demand. Please note a HGDN subscription is required to download code samples
Showing results for 
Search instead for 
Do you mean 

Examples: Control Layers Opacity

by Technical Evangelist on ‎09-09-2015 04:10 AM (352 Views)


Sets the opacity of the layer ("Map Layer" and not the legend item in old portal's wording). Notice: Portal UI accessible from the context menu won't refresh after this operation. It is going to be fixed some day :-)

 * Set legend item opacity (if the legend item is a separate map layer)
 * @param {LegendItem} publicLegendItem - legend item object obtained in $GP.legend.find callback
 * @param {Number} value - opacity value [0,100]
 * @return {Void}
function setOpacity(publicLegendItem, value) {
    var mapLayerConfig = publicLegendItem._.mlc;
    if (!mapLayerConfig) return;
    $event.notify("opacityChanged", {
        mapLayerConfigId: mapLayerConfig.get_id()

Example usage:

    name: "World Map"
}, function(result) {
    if (result.legendItems && result.legendItems.length > 0)
        setOpacity(result.legendItems[0], 50)