Skip to content

Legend - provide a way to hide basemap legend info with one property. #174

@mhdostal

Description

@mhdostal

Currently, there is no easy way to exclude basemaps from displaying in the legend. The AGOL viewers do not seem to provide a way to set the showInLegend property for a basemap to false. Also, many basemaps do not contain useful legend information.

In order to hide basemaps in a legend, you have to loop through all "base" and "reference" layers in a basemap and manually set their showInLegend property to false:

        map?.load { [weak self] error in
            guard error == nil else { return }
            self?.map?.basemap.load { [weak self] error in
                guard error == nil,
                let basemap = self?.map?.basemap else { return }
                _ = basemap.referenceLayers.map { ($0 as? AGSLayerContent)?.showInLegend = false }
                _ = basemap.baseLayers.map { ($0 as? AGSLayerContent)?.showInLegend = false }
            }
        }

It would be very convenient to have a LegendViewController property to hide all basemap data in a legend, such as:

/// A Boolean value indicating whether to show the basemap layers in the legend.
public var showBasemapInLegend: Bool = true

See #173

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions