Drawing polygons in the scene

244
2
Jump to solution
03-22-2024 12:53 AM
lsc
by
New Contributor II

I'm trying to draw a 3D polygon in the scene. But I didn't find the right way. Is there any way to achieve this? The function code is as follows:

function addPolygonGraphic() {

// create the polygon by assigning points
polygonBuilder.addPointXYZ(centerX, centerY, 10000);
polygonBuilder.addPointXYZ(centerX + 0.1, centerY, 10000);
polygonBuilder.addPointXYZ(centerX + 0.1, centerY, 10000);
polygonBuilder.addPointXYZ(centerX, centerY, 10000);

// assign the geometry of the graphic to be the polygon
polygonGraphic.geometry = polygonBuilder.geometry;
// add the graphic to the polygon graphics overlay
graphicsOverlay.graphics.append(polygonGraphic);
}

 

Thank you very much!

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Couple of things to consider:

 

- does the graphics overlay have the surface placement mode set? Here's an example - https://github.com/Esri/arcgis-maps-sdk-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/Scenes/Se... Since you've set z values, you probably want absolute. Here is the doc - https://developers.arcgis.com/qt/qml/api-reference/enums-surfaceplacement.html .

- Have you set the spatial reference of your polygon builder to match whatever the centerX and centerY variables are using?

View solution in original post

2 Replies
LucasDanzinger
Esri Frequent Contributor

Couple of things to consider:

 

- does the graphics overlay have the surface placement mode set? Here's an example - https://github.com/Esri/arcgis-maps-sdk-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/Scenes/Se... Since you've set z values, you probably want absolute. Here is the doc - https://developers.arcgis.com/qt/qml/api-reference/enums-surfaceplacement.html .

- Have you set the spatial reference of your polygon builder to match whatever the centerX and centerY variables are using?

lsc
by
New Contributor II

Thank you very much!

 

0 Kudos