简体   繁体   中英

Can I use ArcGIS REST-API "applyEdits" to update Feature-Layer as an authenticated user?

I'm using nodeJS to edit my Feature-Layer using REST API. My intention is to:

  1. Update my layer using Firebase Cloud-Functions
  2. Share my layer publicly
  3. But keep my layer non-editable for unauthorised users
  4. I want to use my API-Key for authentication.

My problem: If I edit my feature definition to "capabilities" : "Create, Update, Delete" as mentioned here , then any unauthorised user can edit my layer, while if I don't, I get:

[ 'This operation is not supported.', 'Unable to add the features.', 'This operation is not supported.' ]

Authentication is declered in the documentation .

My code:

require("cross-fetch/polyfill");
require("isomorphic-form-data");
const featureLayer = require('@esri/arcgis-rest-feature-layer');
const auth = require('@esri/arcgis-rest-auth');

const apiKey = new auth.ApiKey({key: 'some key...'});
featureLayer.applyEdits({
    url: "https://services3.arcgis.com/someID/arcgis/rest/services/someName/FeatureServer/0",
    adds: [{
      geometry: { x: 120, y: 45 },
      attributes: { indexCity: "alive" }
    }],
    authentication: apiKey
  })
    .then(response => {
      console.log(response)
    })
    .catch(err => console.log(err.response.error.details));

I'm running my code using node example.js in terminal.

How can I define appleEdits only for me as authenticated user?

One option is to make your edits to a private feature layer (that's editable), and then have a public (non-editable) view of that feature layer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM