Adding a raster layer to map

81
0
05-19-2022 01:54 PM
BerndtNording
New Contributor III

In an addin i'm creating there's a button that will add a raster layer to my map based on a selected value in a listbox. The code is simple and works fine: the new layer appears in the TOC and the image appears on the map, but curiously all visibility checkboxes on layers in the TOC become greyed out for a while. After a minute or so, they become enabled again. I'm guessing something is going on in a background thread that is setting the visibility checkboxes to disabled while it is doing whatever it is doing. The question is what is it doing?  The images are around 10mb each and georeferenced.

    private async void cmd_ButtonAdd_Click(Object sender)
    {
      Layer pImgLay;
      string url = selectedObliqueVal;
      url = m_imgPath + m_Isle + m_imgFolder + "A" + url.Substring(1, 1) + @"\" + url + ".jpg";

      if (!System.IO.File.Exists(url))
      {
        MessageBox.Show("File does not exist:\r\n" + url);
        return;
      }
      pImgLay = await QueuedTask.Run(() => { return LayerFactory.Instance.CreateLayer(new Uri(url), MapView.Active.Map); });
      _addedImages.Add(url);
      //MessageBox.Show("Add");
    }

 

0 Kudos
0 Replies