Skip to content

Instantly share code, notes, and snippets.

@Rachael-E
Last active January 20, 2023 11:29
Show Gist options
  • Save Rachael-E/ef500ad5b3d455d3780ba3ce2b24a92a to your computer and use it in GitHub Desktop.
Save Rachael-E/ef500ad5b3d455d3780ba3ce2b24a92a to your computer and use it in GitHub Desktop.
Custom renderer
// Change the web map renderer to a customised one
private func changeFeatureLayerRenderers(for map: AGSMap) {
// Get the feature layer containing the munro mountains point data
if let munroLayer = map.operationalLayers.object(at: 1) as? AGSFeatureLayer {
// Turn off labels
munroLayer.labelsEnabled = false
// Create custom renderer from mountains.png
let munroSymbol = AGSPictureMarkerSymbol(image: UIImage(named: "mountains")!)
munroSymbol.height = 40
munroSymbol.width = 40
munroLayer.renderer = AGSSimpleRenderer(symbol: munroSymbol)
}
// Get the feature layer containing the national park polygon data
if let parkLayer = map.operationalLayers.object(at: 0) as? AGSFeatureLayer {
let parkLineSymbol = AGSSimpleLineSymbol(style: .solid, color: UIColor.black, width: 1)
let parkSymbol = AGSSimpleFillSymbol(style: .null, color: UIColor.clear, outline: parkLineSymbol)
// Create custom renderer
parkLayer.renderer = AGSSimpleRenderer(symbol: parkSymbol)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment