Good Day,
I have been using the code below to zoom to the device's location and add a point feature based on the device's current location by clicking any where on the screen. The feature is being added to the service table however there is no/null geometries for each point therefore it is not showing up on the map. How can I fix this?
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.2
import QtPositioning 5.3
import QtSensors 5.3
MapView{
id: mapView
Map{
id: map
initUrl: "http://melbournedev.maps.arcgis.com/home/webmap/viewer.html?webmap=24ba3f20e7424c67989e64ec740384f8"
FeatureLayer {
id: featureLayer
selectionColor: "cyan"
selectionWidth: 3
// declare as child of feature layer, as featureTable is the default property
ServiceFeatureTable {
id: featureTable
url: "https://services1.arcgis.com/NUSHso3rgWERZOFF/arcgis/rest/services/TestPoint1/FeatureServer/0"
// make sure edits are successfully applied to the service
onApplyEditsStatusChanged: {
if (applyEditsStatus === Enums.TaskStatusCompleted) {
console.log("successfully added feature");
}
}
// signal handler for the asynchronous addFeature method
onAddFeatureStatusChanged: {
if (addFeatureStatus === Enums.TaskStatusCompleted) {
// apply the edits to the service
featureTable.applyEdits();
}
}
}
}
}
locationDisplay {
positionSource: positionSource
compass: compass
}
PositionSource {
id: positionSource
active: true
property bool isInitial: true
onPositionChanged: {
if(map.loadStatus === Enums.LoadStatusLoaded && isInitial) {
isInitial = false;
zoomToCurrentLocation();
}
}
}
Compass {
id: compass
}
function zoomToCurrentLocation(){
positionSource.update ();
var currentPositionPoint = ArcGISRuntimeEnvironment.createObject ("Point", {x: positionSource.position.coordinate.longitude, y: positionSource.position.coordinate.latitude, spatialReference: SpatialReference.createWgs84()});
var centerPoint = GeometryEngine.project(currentPositionPoint, mapView.spatialReference);
var viewPointCenter = ArcGISRuntimeEnvironment.createObject("ViewpointCenter",{center: centerPoint, targetScale: 10000});
mapView.setViewpointWithAnimationCurve(viewPointCenter, 2.0, Enums.AnimationCurveEaseInOutCubic);
}
//! [AddFeaturesFeatureService new feature at mouse click]
onMouseClicked : { // mouseClicked came from the MapView
// create attributes json for the new feature
var featureAttributes = {"Name" : "Test"};
// create a new feature using the mouse's map point
var feature = featureTable.createFeatureWithAttributes(featureAttributes, mapView.locationDisplay.mapPoint);
// add the new feature to the feature table
featureTable.addFeature(feature);
}
}