How to change map brightness

1485
2
Jump to solution
09-10-2017 11:44 AM
AnatBen_Israel
New Contributor II

Hi, I have a Qml MapView which is controlled by a C++ MapQuickView.

I want to try and control the map brightness.

I found the ImageAdjustmentLayer which seems suitable but I can't find how to use it (can't find any code exmaples).

I would appreciate some help and example code.

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Anat, unfortunately there is not currently any API to change the brightness for the whole MapQuickView and all of its contents. You are correct that you could use the ImageAdjustmentLayer to set the brightness for some of the layers in your map - specifically:

- ArcGISMapImageLayer

- ImageTiledLayer

- RasterLayer

Does your map contain any of these layer types? If so, and you want to change the brightness on just these types, I think you could do something like:

1. connect to a UI signal or something when you want to change to a new brightness value

2. get the LayerListModels of operational layers from the map and the base/reference layers from the basemap

3. for each of the models, iterate over the layers and attempt to cast to an ImageAdjustmentLayer

4. if the cast was successful, call setBrightness with the new value

Here is some example code to get your started:

  LayerListModel* operationalLayers = map->operationalLayers();
  LayerListModel* baseLayers = map->basemap()->baseLayers();
  LayerListModel* refLayers = map->basemap()->referenceLayers();

  for (LayerListModel* model : {operationalLayers, baseLayers, refLayers})
  {
    for (int i = 0; i < model->rowCount(); ++i)
    {
      Layer* layer = model->at(i);
      if (!layer)
        continue;
      ImageAdjustmentLayer* imageAdjustmentLyr = qobject_cast<ImageAdjustmentLayer*>(layer);
      if (!imageAdjustmentLyr)
        continue;
      imageAdjustmentLyr->setBrightness(newBrightness);
    }
  }

I hope that helps.

Luke

View solution in original post

0 Kudos
2 Replies
LukeSmallwood
Esri Contributor

Hi Anat, unfortunately there is not currently any API to change the brightness for the whole MapQuickView and all of its contents. You are correct that you could use the ImageAdjustmentLayer to set the brightness for some of the layers in your map - specifically:

- ArcGISMapImageLayer

- ImageTiledLayer

- RasterLayer

Does your map contain any of these layer types? If so, and you want to change the brightness on just these types, I think you could do something like:

1. connect to a UI signal or something when you want to change to a new brightness value

2. get the LayerListModels of operational layers from the map and the base/reference layers from the basemap

3. for each of the models, iterate over the layers and attempt to cast to an ImageAdjustmentLayer

4. if the cast was successful, call setBrightness with the new value

Here is some example code to get your started:

  LayerListModel* operationalLayers = map->operationalLayers();
  LayerListModel* baseLayers = map->basemap()->baseLayers();
  LayerListModel* refLayers = map->basemap()->referenceLayers();

  for (LayerListModel* model : {operationalLayers, baseLayers, refLayers})
  {
    for (int i = 0; i < model->rowCount(); ++i)
    {
      Layer* layer = model->at(i);
      if (!layer)
        continue;
      ImageAdjustmentLayer* imageAdjustmentLyr = qobject_cast<ImageAdjustmentLayer*>(layer);
      if (!imageAdjustmentLyr)
        continue;
      imageAdjustmentLyr->setBrightness(newBrightness);
    }
  }

I hope that helps.

Luke

0 Kudos
AnatBen_Israel
New Contributor II

Super helps!!

Works perfect. Thanks so much!

0 Kudos