Hi Community!
I am looking to attach AGSTextSymbols to a polygon by using `
AGSGeometryEngine.labelPoint(for: polygon)`, which returns a point.
How can I place the text symbol at that point?
I've made many polygons and even extruded them in AR space. I just can't figure out how to set a 3D text billboard or object at a specific AGSPoint.
Thanks so much!
Solved! Go to Solution.
Hi Andrew,
You may do that by
1. Create a text symbol, i.e. AGSTextSymbol
2. Create a graphic with the point from your polygon, and the symbol with the text symbol, i.e. AGSGraphic(geometry: point, symbol: textSymbol)
3. Add the graphic to your scene's graphic overlays
4. Set the graphic overlay's sceneProperties to the one you want, e.g. draped, flat, billboarded, etc.
Take a look at this sample https://github.com/Esri/arcgis-runtime-samples-ios/tree/main/arcgis-ios-sdk-samples/Scenes/Surface%2... to see if it helps. Let me know if you've other questions.
Ting
Hi Andrew,
You may do that by
1. Create a text symbol, i.e. AGSTextSymbol
2. Create a graphic with the point from your polygon, and the symbol with the text symbol, i.e. AGSGraphic(geometry: point, symbol: textSymbol)
3. Add the graphic to your scene's graphic overlays
4. Set the graphic overlay's sceneProperties to the one you want, e.g. draped, flat, billboarded, etc.
Take a look at this sample https://github.com/Esri/arcgis-runtime-samples-ios/tree/main/arcgis-ios-sdk-samples/Scenes/Surface%2... to see if it helps. Let me know if you've other questions.
Ting
Thank you, @Ting ! I was just getting confused about AGSLabelDefinition and all the other stuff, like features layers and stuff. This is just simple and pure creating and placing objects. I guess I forgot that I need to combine the symbol with the point inside a new AGSGraphic. I'll give it a try and get back to you Thanks so much for the quick reply!
Do I need to set a renderer and add it to the graphics overlay? The renderer requires a symbol. Do I add the text symbol as the renderer symbol, or some other symbol, like a line?
I guess the answer is no, you don't need to set a renderer on the graphics overlay. Check out the doc for AGSSimpleRenderer. Basically, a render is a handy tool if you want to use the same symbol for various geometries. E.g., you want to use a restaurant image swatch for all the restaurants on the map.
In terms of text symbols, the simpler way would be creating a different text symbol for each different text/string. Based on your description, I don't think you'll use the same text symbol for different polygons (because the text varies), so you'll need to create a text symbol to create one graphic, for each polygon, and add all the graphics to the graphics overlay.
Furthermore, if you want to combine 2 symbols together (say you want to add a text to a map pin), check out AGSCompositeSymbol. It can bind multiple symbols together, and you can customize their position with offsets. e.g.
let compositeSymbol = AGSCompositeSymbol(symbols: [markerSymbol, textSymbol])
That makes a lot of sense. Thanks so much!