Customizing the Add Features template

566
5
09-24-2018 10:13 AM
GiatriLalla
New Contributor III

Good Day,

After numerous failed attempts, I was successful in adding features to my feature class using the Add Feature Template in AppStudio. Now, I want these features to have its attributes as its x and y position or lat and long position as well as a user name. How can this be done? I tried using the code below but it did not run, 

Map { id: map anchors.fill: parent wrapAroundEnabled: true FeatureLayer { id: featureLayer featureTable: featureServiceTable //when the user clicks on the map, add feature to the feature layer with the mouse coordinates as geometry, and predefined attributes onMouseClicked: { var featureJson = { geometry: { x: mouse.mapX, y: mouse.mapY, spatialReference: mouse.mapPoint.spatialReference }, attributes: { TYPEDAMAGE: "Minor", PRIMCAUSE: "Earthquake", TYPEDAMAGE_INT: 3 } } if (featureServiceTable.featureTableStatus === Enums.FeatureTableStatusInitialized) { featureServiceTable.addFeature(featureJson) } } }

Below is a picture of the current attribute table that I want to populate with data. Attribute Table

0 Kudos
5 Replies
ErwinSoekianto
Esri Regular Contributor

Giatri, 

It is hard to read your code without proper indentation. Also when you say it does not run, what is the error message? 

Thank you,

Erwin.

0 Kudos
GiatriLalla
New Contributor III

Hi, thank you for the quick reply. The code used is the “Add Feature” code on this document Edit features—ArcGIS Runtime SDK for Qt | ArcGIS for Developers 

Secondly, I did not get an error message when I ran the code. I simply was not able to add a feature. For example, when I clicked the screen, no points were showing up. 

0 Kudos
ErwinSoekianto
Esri Regular Contributor

It should work. Did you try to adjust the code to follow your codebase and your Feature Layer content? 

ArcGIS Runtime SDK for Qt‌ , mentioning Runtime QT to see if anyone else have the same issue in that group. 

0 Kudos
GiatriLalla
New Contributor III

Ok. I’ll retry the code and give you an update. As for searching similar problems, I came up empty handed.

Apart from that code, I’ve also used the Add Feature template in AppStudio 3.0 which allows me to add  a feature to my Service Feature Table (as shown in the picture). How can I obtain the x and y values of the point Feature in the attribute table? 

0 Kudos
ErwinSoekianto
Esri Regular Contributor

It depends on the type of object you are working with, 

  • If it is Point QML Type already, then there are "x" and "y" property already in this