Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mhdostal opened this issue Apr 28, 2022 · 0 comments
Open

Comments

@mhdostal
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant