I want to draw line. But, I can't
Where I mistake?
My code:
import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.9
ApplicationWindow {
id: appWindow
width: 800
height: 600
title: "MapTest2"
// add a mapView component
MapView {
id: mapView
anchors.fill: parent
// set focus to enable keyboard navigation
focus: true
// add a map to the mapview
Map {
// add the BasemapTopographic basemap to the map
BasemapTopographic {}
}
onMouseClicked: {
pointBuilder.points.addPointXY(0, 35)
pointBuilder.points.addPointXY(135, 35)
lineBuilder.points.addPointXY(0, 35)
lineBuilder.points.addPointXY(135, 35)
pointA.geometry = pointBuilder.geometry
lineA.geometry = lineBuilder.geometry
}
GraphicsOverlay {
id: overlay
Graphic {
id: pointA
zIndex: 2
SimpleMarkerSymbol {
color: "red"
size: 15
style: Enums.SimpleMarkerSymbolStyleCircle
}
}
Graphic{
id: lineA
zIndex: 1
SimpleLineSymbol {
id: simpleLineSymbol
style: Enums.SimpleLineSymbolStyleDash
width: 10
color: "green"
}
}
}
MultipointBuilder{
id: pointBuilder
spatialReference: SpatialReference {
wkid: 6668
}
}
MultipointBuilder{
id: lineBuilder
spatialReference: SpatialReference {
wkid: 6668
}
}
}
}
This code can draw point.
Solved! Go to Solution.
Hi @KanjaSousuke, thanks for reaching out. Fortunately this is a fairly easy fix. You'll need to use a PolylineBuilder instead of a MultipointBuilder when creating the line geometry. The PolylineBuilder does not have a points property, so you will also need to remove that when constructing your geometries. Updating the following lines should resolve your issue.
27 lineBuilder.addPointXY(0, 35)
28 lineBuilder.addPointXY(135, 35)
67 PolylineBuilder {
For more information about creating geometries in QML, I recommend taking a look at our Create geometries sample.
Thank you and please don't hesitate to follow up if there's anything else I can help with!
Hi @KanjaSousuke, thanks for reaching out. Fortunately this is a fairly easy fix. You'll need to use a PolylineBuilder instead of a MultipointBuilder when creating the line geometry. The PolylineBuilder does not have a points property, so you will also need to remove that when constructing your geometries. Updating the following lines should resolve your issue.
27 lineBuilder.addPointXY(0, 35)
28 lineBuilder.addPointXY(135, 35)
67 PolylineBuilder {
For more information about creating geometries in QML, I recommend taking a look at our Create geometries sample.
Thank you and please don't hesitate to follow up if there's anything else I can help with!
Sorry, It was a simple misunderstanding on my part.
Thank you for bringing that to my attention.
@KanjMadi the 100.12 release of ArcGIS Runtime now supports a SketchEditor, which greatly simplifies the workflow for sketching geometries on a map. This might be something worth considering integrating into your app. More details are in the release blog - https://community.esri.com/t5/arcgis-runtime-sdks-blog/sketcheditor-now-available-in-the-arcgis-runt...