I drawed polyline in my application but I can't create a new one in line layer.
Here is my code beolow:
Here is my consol output below:
Thanks.
Problem solved when I set symbolid value,line appeared on map.Because symbolid value was null.
var feature = ArcGISRuntime.createObject("Feature");
feature.geometry = userPolyline;
feature.setAttributeValue("symbolid",'19');
offLineLayer.featureTable.addFeature(feature);
Thanks Lucas .
Hi,
Here is the project below:
// Copyright 2015 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// See the Sample code usage restrictions document for further information.
import QtQuick 2.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import ArcGIS.Runtime.Toolkit.Dialogs 1.0
import ArcGIS.Runtime.Toolkit.Controls 1.0
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import ArcGIS.Extras 1.0
import ArcGIS.Runtime 10.25
ApplicationWindow {
id: appWindow
width: 800
height: 600
title: "OfflinePolygonEditing"
property double scaleFactor: System.displayScaleFactor
property bool firstPoint: true
property bool firstLinePoint: true
property bool createPoint: false
property bool isDone: false
property int polyGraphicId
property int lineGraphicId
property int fontSize: 15 * scaleFactor
property bool isOnline: true
property string featuresUrl: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/WildfireSync/FeatureServer"
property string gdbPath: "~/ArcGIS/Runtime/Data/Test/offlineSample.geodatabase"
property var selectedFeatureId: null
property var xProp: null
property var yProp: null
Envelope
{
id: sfExtent
xMin: 1930934.6938406308 //turkey
yMin: 3850498.260784086
xMax: 5912392.6567565575
yMax: 5564737.105928443
spatialReference: mainMap.spatialReference
}
Map {
id: mainMap
anchors.fill: parent
extent: sfExtent
focus: true
ArcGISTiledMapServiceLayer {
url: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"
FeatureLayer
id: offLineLayer
featureTable: appWindow.isOnline ? featureServiceTable : local
selectionColor: "cyan"
GraphicsLayer {
id: graphicsLayer
onStatusChanged: {
if (status === Enums.MapStatusReady) {
onMouseClicked: {
if (isDone)
return;
if(createPoint)
addLinePoint(mouse.mapPoint);
else
addPoint(mouse.mapPoint);
//END MAP
GeodatabaseFeatureTable {
id: local
geodatabase: gdb.valid ? gdb : null
featureServiceLayerId: 0
GeodatabaseFeatureServiceTable {
id: featureServiceTable
url: featuresUrl + "/1"
ServiceInfoTask {
id: serviceInfoTask
url: featuresUrl
onFeatureServiceInfoStatusChanged:{
if (featureServiceInfoStatus === Enums.FeatureServiceInfoStatusCompleted)
statusText.text = "Servis bilgisi alındı.Çalışma Alanı çizimini yapın";
else if (featureServiceInfoStatus === Enums.FeatureServiceInfoStatusErrored) {
statusText.text = "Error:";
generateButton.enabled = false;
cancelButton.text = "Start Over";
Feature {
id: featureToEdit
Rectangle {
anchors {
fill: controlsColumn
margins: -10 * scaleFactor
color: "lightgrey"
radius: 5 * scaleFactor
border.color: "black"
opacity: 0.77
MouseArea {
onClicked: (mouse.accepted = true)
Column {
id: controlsColumn
left: parent.left
top: parent.top
margins: 20 * scaleFactor
spacing: 7
Row {
id: row
spacing: 10 * scaleFactor
Button {
id:silButton
text: "Çalışma Alanı Sil"
enabled: false
width: generateButton.width
style: ButtonStyle {
label: Text {
text: control.text
color: control.enabled ? "black" : "grey"
horizontalAlignment: Text.AlignHCenter
onClicked: {
if (userPolygon.pathCount > 0)
userPolygon.removePath(0);
isDone = false;
firstPoint = true;
graphicsLayer.removeAllGraphics();
generateButton.enabled=false;
id: generateButton
text: "Geodatabase Oluştur"
generateGeodatabaseParameters.initialize(serviceInfoTask.featureServiceInfo);
generateGeodatabaseParameters.extent = userPolygon;
generateGeodatabaseParameters.returnAttachments = false;
statusText.text = "Starting generate geodatabase task";
geodatabaseSyncTask.generateGeodatabase(generateGeodatabaseParameters, gdbPath);
id: syncButton
text: "Sync"
style: generateButton.style
enabled = false;
geodatabaseSyncTask.syncGeodatabase(gdb.syncGeodatabaseParameters, gdb);
statusText.text = "Starting sync task";
id: cancelButton
text: "İptal"
geodatabaseSyncTask.cancelJob(syncStatusInfo);
text = "İptal";
id: toggleOnlineOffline
spacing: 10
Text {
id: onlineStatus
text: appWindow.isOnline ? " Online " : " Offline "
color: "black"
Switch {
id: switchToggle
checked: appWindow.isOnline
onCheckedChanged: {
appWindow.isOnline = checked;
if (checked === true && Enums.GenerateStatusCompleted)
statusText.text = "Switch to Offline Mode to continue editing.";
else if (checked === false && Enums.GenerateStatusCompleted)
statusText.text = "Select a feature.";
Geodatabase {
id: gdb
path: geodatabaseSyncTask.geodatabasePath
onValidChanged: {
if (valid) {
var gdbtables = gdb.geodatabaseFeatureTables;
for(var i in gdbtables) {
console.log (gdbtables.featureServiceLayerName);
GeodatabaseSyncStatusInfo {
id: syncStatusInfo
GeodatabaseSyncTask {
id: geodatabaseSyncTask
onGenerateStatusChanged: {
if (generateStatus === Enums.GenerateStatusCompleted)
statusText.text = geodatabasePath;
cancelButton.enabled = false;
appWindow.isOnline = false;
statusText.text = "Feature Oluştur";
createPoint= true;
else if (generateStatus === GeodatabaseSyncTask.GenerateError)
statusText.text = "Error: " + generateGeodatabaseError.message + " Code= " + generateGeodatabaseError.code.toString() + " " + generateGeodatabaseError.details;
onGeodatabaseSyncStatusInfoChanged: {
if (geodatabaseSyncStatusInfo.status === Enums.GeodatabaseStatusUploadingDelta) {
var deltaProgress = geodatabaseSyncStatusInfo.deltaUploadProgress/1000;
var deltaSize = geodatabaseSyncStatusInfo.deltaSize/1000;
statusText.text = geodatabaseSyncStatusInfo.statusString + " " + String(deltaProgress) + " of " + String(deltaSize) + " KBs...";
} else
statusText.text = geodatabaseSyncStatusInfo.statusString + "...";
if (geodatabaseSyncStatusInfo.status !== GeodatabaseSyncStatusInfo.Cancelled)
cancelButton.enabled = true;
syncStatusInfo.json = geodatabaseSyncStatusInfo.json;
onSyncStatusChanged: {
featureServiceTable.refreshFeatures();
if (syncStatus === Enums.SyncStatusCompleted) {
syncButton.enabled = false;
statusText.text = "Sync tamamlandı.Feature editlemeye devam edebilirsin.";
switchToggle.enabled = true;
if (syncStatus === Enums.SyncStatusErrored)
statusText.text = "Error: " + syncGeodatabaseError.message + " Code= " + syncGeodatabaseError.code.toString() + " " + syncGeodatabaseError.details;
GenerateGeodatabaseParameters {
id: generateGeodatabaseParameters
id: textStatusRectangle
fill: statusText
visible: statusText.text.length > 0
radius: 5
id: statusText
right: parent.right
bottom: parent.bottom
wrapMode: Text.WordWrap
Component.onCompleted:
statusText.text = "Getting service info";
serviceInfoTask.fetchFeatureServiceInfo();
Polygon {
id: userPolygon
Polyline {
id: userPolyline
Graphic {
id: redPointGraphic
symbol: SimpleMarkerSymbol {
color: "red"
style: Enums.SimpleMarkerSymbolStyleCircle
size: 5
id: polygonGraphic
symbol: SimpleFillSymbol {
color: Qt.rgba(0.5, 0, 0.0, 0.25)
outline: SimpleLineSymbol {
style: Enums.SimpleLineSymbolStyleSolid
width: 2
id: blueLineGraphic
symbol: SimpleLineSymbol {
color: "blue"
width: 5
id: bluePointGraphic
function addPoint(mapPoint) {
var newPoint = redPointGraphic.clone();
newPoint.geometry = mapPoint;
graphicsLayer.addGraphic(newPoint);
var graphicClone = polygonGraphic.clone();
if (firstPoint) {
firstPoint = false;
userPolygon.startPath(mapPoint.x, mapPoint.y);
graphicClone.geometry = userPolygon;
polyGraphicId = graphicsLayer.addGraphic(graphicClone);
} else {
userPolygon.lineTo(mapPoint.x, mapPoint.y);
graphicsLayer.updateGraphic(polyGraphicId, graphicClone);
if (userPolygon.pointCount > 2)
silButton.enabled = true
generateButton.enabled = true;//tener ekledi
statusText.text = "Geodatabase Oluştur Buttonuna basın";//eski
function addLinePoint(mapPoint)
var newPoint = bluePointGraphic.clone();
var graphicClone;
graphicClone = blueLineGraphic.clone();
if (firstLinePoint) {
firstLinePoint = false;
userPolyline.startPath(mapPoint.x, mapPoint.y);
graphicClone.geometry = userPolyline;
lineGraphicId = graphicsLayer.addGraphic(graphicClone);
userPolyline.lineTo(mapPoint.x, mapPoint.y);
graphicsLayer.updateGraphic(lineGraphicId, graphicClone);
loadLayerColumn.visible = true;
color: "transparent"
border {
width: 0.5 * scaleFactor
visible: loadLayerColumn.visible
fill: loadLayerColumn
ColumnLayout {
id: loadLayerColumn
visible: false
text: "Descrption özellik değerini gir"
TextField {
id: featureTextField
Layout.fillWidth: true
visible:true
text: "Özellik Değeri"
id: okButton
text: "Ok"
messageDialog.text = "";
loadLayerColumn.visible = false;
syncButton.enabled = true;
statusText.text = "Feature Servise düzenlemeleri kaydetme için Sync butonuna bas";
MessageDialog
id: messageDialog
title: "Error"
icon: StandardIcon.Warning
modality: Qt.WindowModal
standardButtons: StandardButton.Ok
onClicked: loadLayerColumn.visible = false
KK-
Can you please post your project, or a snippet that reproduces the issue?
Thanks,
Luke
I changed my code like your code but polyline cannot created.Below is console output :
I suggest you try something like the following:
var feature = ArcGISRuntime.createObject("Feature"); feature.geometry = userPolyline; offlineLayer.featureTable.addFeature(feature);
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.