updateFeature not for geometry position?

1864
1
05-25-2016 07:41 AM
TestAppStudio
New Contributor

Hello,

i'd like to change the given position of a selected Feature to my GPS position. For testing i also changed some attribute values. After the update i can see the changes on my map until i restart the app but only the changes to the attributes are persistent.

I tried to replace the existing geometry with an new created from my GPS postion.

My second try was to use the setXY function of the geometry object with the projected GPS coordinates.

Both ways work on the screen/app but not the data behind (feature layer in arcgis online). Only the attribut values are updated.

Button{
  text: "Update"
  onClicked: {
    featureToEdit = featureLayer.featureTable.feature(hitFeatureId)
    if (featureToEdit) {
      var saveX = featureToEdit.geometry.x.toFixed(3)
      featureToEdit.geometry = posGPS.project(featureToEdit.geometry.spatialReference)
      var newX = featureToEdit.geometry.x.toFixed(3)
      featureToEdit.setAttributeValue("description",("old: " + saveX + "; new: " + newX))
      featureServiceTable.updateFeature(hitFeatureId, featureToEdit);
      featureServiceTable.applyFeatureEdits();
    }
  }
}

My workaround is to delete the original feature and place a copy on the new position.

Poor performance solution on refreshing the map to show the features again. (Only panning the map helps to redraw the features)

Maybe anyone can tell me how to update the position in the right way?

Best regards, Christian

0 Kudos
1 Reply
by Anonymous User
Not applicable

Hi Christian

I remember having the same issue back around Sep last year when AppStudio still in Beta and discussed it with ESRI but I'm not sure if they ever resolved it.

For me, I found that the updateFeature didn't update the geometry if I was trying to use a GeodatabaseFeatureServiceTable. However, the app I was building at the time used offline geodatabases, and the updateFeature method worked fine for a GeodatabaseFeatureTable, so I never followed it up any further myself at the time.

Drop me a line at paul@gpsit.co.nz if you like and I can forward you an email from back then outlining what I tested and who I spoke with if you think it would help.

Cheers,

-Paul

0 Kudos