Good afternoon, I got the following code which starts at constructor AppEditor() and I'm handling mouse clicks to place markerGraphics at the clicked position. All works well so far except the method stopPlacingMarkers(), which is called from a button on the UI, display an empty polyBuilder-ToGeometry(). Shouldn't the markerPosition X and Y addPoint be in there?
How would I go about appending all mouse click markerGraphics so that it is available in the last method qDebug()?
void AppEditor::AppEditor()
{
Esri::ArcGISRuntime::PolylineBuilder* polyBuilder = new PolylineBuilder(SpatialReference::wgs84(), this);
Esri::ArcGISRuntime::SimpleMarkerSymbol* markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Square, QColor(Qt::black), 2.0, this);
}
void AppEditor::createdMarkerOnMap(Point markerPosition)
{
polyBuilder->addPoint(markerPosition.x(), markerPosition.y());
// create a graphic from clicked marker position
Esri::ArcGISRuntime::Graphic* markerGraphic = new Graphic(polyBuilder->toGeometry(), markerSymbol, this);
// add to graphics overlay and display on map
graphicsOverlay->graphics()->append(markerGraphic);
}
void AppEditor::stopPlacingMarkers()
{
// output polyBuilder point(s)
qDebug() << polyBuilder->toGeometry();
}
Thanks for any tips / help.
Solved! Go to Solution.
A quick way to see the x/y values of a polyBuilder would be to convert the geometry to JSON:
qDebug() << PolyBuilder->toGeometry().toJson();
This will give you something like:
"{\"hasZ\":true,\"paths\":[[[-160,34,0],[-175,40,25],[-182,36,0]]],\"spatialReference\":{\"wkid\":4326}}"
A quick way to see the x/y values of a polyBuilder would be to convert the geometry to JSON:
qDebug() << PolyBuilder->toGeometry().toJson();
This will give you something like:
"{\"hasZ\":true,\"paths\":[[[-160,34,0],[-175,40,25],[-182,36,0]]],\"spatialReference\":{\"wkid\":4326}}"
Good catch, never noticed that .toJson() method.
Thank you!