Two questions:
If a layer has more than one legendInfos can we use the symbols in all the legendInfos to create AGSCompositeSymbol and then swatch? or AGSCompositeSymbol is different?
If there are different type of layers, what is common way for get Symbol, e.g. map have AGSArcGISMapImageLayer its legendInfos are 0. However when I use LegendViewController from one of your examples, it load the symbol.
Solved! Go to Solution.
Thank you for the further explanation and the code. The error is `Invalid geometry type`. My guess is that you are mixing point, line, and polygons symbols in your composite symbol. They all need to be the same geometry type when added to the composite symbol. Please double-check the symbol types (point/line/fill) that get added to the composite symbol.
Let me know how that goes,
Mark
Thank you for your question! It is possible to use the symbols in the legendInfos to create a composite symbol. What would be the use case for doing that? A legendInfo represents one individual legend element, so combining their symbols may be confusing. Example: each of the rows (Food, Fun, Design) in the image below is represented by a single legendInfo.
As for `AGSArcGISMapImageLayer`, each of it's sublayers is also "Loadable", which means you need to load them explicitly in order to have their properties populated. If you look in `LegendViewController.swift`, in the method loadIndividualLayer, it loads the layer, then calls loadSublayersOrLegendInfos, which loads the sublayers. Only after the sublayers are loaded does it call fetchLegendInfos and get the legendInfos it uses to build the legend.
So I suspect if you explicitly load the sublayers before calling fetchLegendInfos, you should be OK.
Please let us know if you need more information or have more questions.
Mark
Thanks Mark,
We were designing our own legend screen which have one image one left side of layer name. So we were thinking to create composite symbol from symbols in legendinfos of each layer, however it created swatch for one layer and was giving error for other.
Do you think its a good idea to create composite symbol from legendinfos of one layer? The example in your response, is San Diego Places one layer?
The San Diego Places is one layer; the data in the layer is symbolized using "Unique Values". The LegendInfos represent those unique values and are what is drawn in the image I posted. The web map used in the Legend example is here. You can take a look at the various layers, how they are symbolized and how they appear in the map's legend in the online map viewer.
The LegendInfo mechanism was designed to be displayed with the symbol/name given, so creating a composite symbol is not really standard.
The swatch should be created from the symbol property of the LegendInfo. You can see that in the LegendViewController here.
If you're still seeing the error, you can send it to me along with an explanation/code snippet of what you're doing and I can take a look.
Mark
I dont get error creating swatch from single legendinfo symbol, the error i get is when i create a composite swatch. Following is the code, symbols is an array contains symbols from legendinfos
let compositeSymbol = AGSCompositeSymbol(symbols: symbols)
compositeSymbol.createSwatch(completion: { (image, error) in
if let img = image {
print("Composite Legend image: \(img)")
self.layerLegend.append(img)
self.delegate?.legendUpdated(images: self.layerLegend)
} else {
print("Composite Legend Image error: \(error?.localizedDescription)")
}
})
The error i get is:
ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error: Error Domain=com.esri.arcgis.runtime.error Code=2 "Invalid argument" UserInfo={NSLocalizedFailureReason=Invalid geometry type., NSLocalizedDescription=Invalid argument, Additional Message=Invalid geometry type.
Thank you for the further explanation and the code. The error is `Invalid geometry type`. My guess is that you are mixing point, line, and polygons symbols in your composite symbol. They all need to be the same geometry type when added to the composite symbol. Please double-check the symbol types (point/line/fill) that get added to the composite symbol.
Let me know how that goes,
Mark
Hi Mark,
Thanks for your response. May the thats the reason the creating composite symbol giving error, have not explored it as the team have decided to go on with showing the legend images individually base on your first comment.
Thank you.
Ok, great. Let us know if you run into any more issues or have additional questions!
Mark