Select to view content in your preferred language

Disable scaling feature in Editor widget

253
4
a month ago
achyl
by
New Contributor

Hi, how can i disable scaling in editor widget?
I would like to disable scaling for CityFurnitureLayer when creating and updating.

const editor = new Editor({
  view: view,
  layerInfos: [
    CityFurnitureInfos(CityFurnitureLayer, content),
    VegetationInfos(VegetationLayer, content),
    BaseInfos(BaseLayer, content),
    PathInfos(pathLayer, content),
  ],
  tooltipOptions: { enabled: true },
  labelOptions: { enabled: true }
});

export const CityFurnitureInfos = (CityFurnitureLayer, content) => {
  return {
    layer: CityFurnitureLayer,
    formTemplate: {
      elements: [
        {
          type: 'field',
          fieldName: 'TYPE',
          label: content.furnitureInfos.labelType
        },
        {
          type: 'field',
          fieldName: 'SIZE',
          label: content.furnitureInfos.labelSize,
          formatter: function (value) {
                return value.toFixed(2);
              },
              format: {
                places: 2,
                digitSeparator: true
              },
              editorType: 'number'
        },
        {
          type: 'field',
          fieldName: 'ROTATION',
          label: content.furnitureInfos.labelRotation,
        }
      ]
    },
    fieldInfos:  [{
        fieldName: 'SIZE',
        label: content.furnitureInfos.labelSize,
        format: {
          places: 2,
          digitSeparator: true
        }
      }]
  };
};
0 Kudos
4 Replies
JoelBennett
MVP Regular Contributor

You can disable scaling on updates like so:

editor.viewModel.sketchViewModel.defaultUpdateOptions.enableScaling = false;

 

Unfortunately, the defaultCreateOptions provide no such property.   They do have a preserveAspectRatio property though which may be helpful, as does defaultUpdateOptions:

editor.viewModel.sketchViewModel.defaultCreateOptions.preserveAspectRatio = false;
0 Kudos
achyl
by
New Contributor

It didn't work,
I set this property in editor.when(), but when I create a new object, this property is overwritten


Zrzut ekranu 2024-05-28 082920.png

 

0 Kudos
Jan62
by
New Contributor

We have the same problem. It seems, only 4.29 is affectet under 4.28 it works fine. The the Sandbox Code.

4.28 Works as intended

<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Edit features with the Editor widget | Sample | ArcGIS Maps SDK for JavaScript 4.29</title>

  <link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css" />
  <script src="https://js.arcgis.com/4.28/"></script>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }

  </style>

  <script>
    require([
        "esri/WebMap",
        "esri/views/MapView",
        "esri/widgets/Editor"
      ], (
        WebMap, MapView,
        Editor
      ) => {

        // Create a map from the referenced webmap item id
        const webmap = new WebMap({
          portalItem: {
            id: "4793230052ed498ebf1c7bed9966bd35"
          }
        });

        const view = new MapView({
          container: "viewDiv",
          map: webmap
        });

        view.when(() => {
          const editor = new Editor({
            view: view,
          });
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableRotation  = true;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableScaling  = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableZ  = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.multipleSelectionEnabled = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.preserveAspectRatio  = true;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.toggleToolOnClick = false;
          editor.viewModel.sketchViewModel.tool = "transform";
          

          // Add the widget to the view
          view.ui.add(editor, "top-right");
        });
      });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>

4.29 Overrides the defaults and enables scaling

<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Edit features with the Editor widget | Sample | ArcGIS Maps SDK for JavaScript 4.29</title>

  <link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css" />
  <script src="https://js.arcgis.com/4.29/"></script>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }

  </style>

  <script>
    require([
        "esri/WebMap",
        "esri/views/MapView",
        "esri/widgets/Editor"
      ], (
        WebMap, MapView,
        Editor
      ) => {

        // Create a map from the referenced webmap item id
        const webmap = new WebMap({
          portalItem: {
            id: "4793230052ed498ebf1c7bed9966bd35"
          }
        });

        const view = new MapView({
          container: "viewDiv",
          map: webmap
        });

        view.when(() => {
          const editor = new Editor({
            view: view,
          });
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableRotation  = true;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableScaling  = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.enableZ  = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.multipleSelectionEnabled = false;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.preserveAspectRatio  = true;
          editor.viewModel.sketchViewModel.defaultUpdateOptions.toggleToolOnClick = false;
          editor.viewModel.sketchViewModel.tool = "transform";
          

          // Add the widget to the view
          view.ui.add(editor, "top-right");
        });
      });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>

 

 

0 Kudos
achyl
by
New Contributor

Thank you,
after downgrading version it works, but only for 2D objects, I can't lock the scaling of a point-3d type symbol.

0 Kudos