In 10.2.5 I was able to create a FeatureLayer with a selectionSymbol which made it possible to create a solid thick border on the selected feature. In version 100.x I'm only able to set .selectionColor and .selectionWidth.
How can I create the selection effect I want in 100.x?
My users should be able to pick multiple existing features and create a new one based on the selected ones. While selecting it is important that the users see the selections clearly.
Thank you for your question! With the current API, you are able to create a thick border around a feature. Here's the same symbol, one unselected and one selected with the selectionColor = .black and the selectionWidth = 2.0.
If that's not what you need, what selection effect are you looking for?
Thank you,
Mark
Thank you for your respons. What I'm looking for selection that changes the polygon completely. Most importantly a clear and solid border, not a faded one like the selectionColor and width creates now. Previous SDK version had selectionSymbol, but it seams to be gone?
Yes, the selectionSymbol property has been removed, in favor of the selectionColor and selectionWidth.
As a work around, one possibility to get the result you desire is to add a GraphicsOverlay to the map to handle the selection. When the user selects a feature, a graphic is added to the overlay with the same geometry as the selected feature and a custom symbol. Clearing the "selection" is just a matter of removing the graphic from the overlay.
// create the overlay
let selectionOverlay = AGSGraphicsOverlay()
//add the overlay to a mapView
mapView.graphicsOverlays.add(selectionOverlay)
//In the selection code (in my case it's the geoView.identifyLayers completion handler)
//create your custom symbol
let symbol = AGSSimpleMarkerSymbol(style: .circle, color: .red, size: 12.0)
//"unselect" all features
self?.selectionOverlay.graphics.removeAllObjects()
//loop through selected geoElements
for geoElement in geoElements {
//create the graphic with the geoElement's geometry and our selection symbol
let graphic = AGSGraphic(geometry: geoElement.geometry, symbol: symbol, attributes: nil)
//add the graphic to our selection overlay
self?.selectionOverlay.graphics.add(graphic)
}
Let me know how this works for you.
Mark
Thanks, this works. I have already implemented a similar approach. Just would wish that .selectionSymbol wasn't removed, when this would be a much simpler approach...