Disable Move/Scale/Rotate on Editor widget

6506
18
04-23-2015 01:26 AM
CiprianLazar
New Contributor III

Hi,

I'm new to Web AppBuilder and JavaScript API and I'm implementing a small app for digitizing features over a orthophoto map. I'm using the developer version of the Web AppBuilder and an intranet Portal for ArcGIS.

I need to set a maximum scale for the map and disable the move/scale/rotate options when using the default editor widget.

I couldn't find a way to set a maximum scale for the map after the initialization of the map (ie when the editor widget is started), but I hooked to the "zoom-end" event of the map and if the user zooms out, the app automatically zooms back in. Is there a better way to do this?

this.blockScaleEvent =
  this.map.on("zoom-end", lang.hitch(this, function () {
       if (this.map.getScale() > 250) {
            this.map.setScale(250);
       }
  }));

I couldn't find a way to disable the move/scale/rotate options when using the default editor widget. Can anyone help me with this?

Thank you,

Ciprian

0 Kudos
18 Replies
JeremieCornet1
Occasional Contributor II

Hi,

In map, you have methods to disable navigation :

Map | API Reference | ArcGIS API for JavaScript

disableClickRecenter()NoneDisallows clicking on a map to center it.
disableDoubleClickZoom()NoneDisallows double clicking on a map to zoom in a level and center the map.
disableKeyboardNavigation()NoneDisallows panning and zooming using the keyboard.
disableMapNavigation()NoneDisallows all map navigation except the slider and pan arrows.
disablePan()NoneDisallows panning a map using the mouse.
disableRubberBandZoom()NoneDisallows zooming in or out on a map using a bounding box.
disableScrollWheelZoom()NoneDisallows zooming in or out on a map using the mouse scroll wheel.
disableShiftDoubleClickZoom()NoneDisallows shift double clicking on a map to zoom in a level and center the map.

hidePanArrows()NoneHides the pan arrows from the map.
hideZoomSlider()NoneHides the zoom slider from the map.

https://developers.arcgis.com/javascript/jsapi/map.html#hidezoomslider

CiprianLazar
New Contributor III

Hi,

I don't want to disable all the zoom and pan options. I just want to force the user to digitize the features at a maximum scale to ensure a required accuracy. He must be able to zoom in and out, just not out of a predefined scale when the editor widget is active.

The code I wrote achieves that, but not in an optimum way. There are some "Request canceled" messages in the console every time the user tries to zoom out of the allowed scale. There is also an unnecessary zoom-out -> zoom-in animation.

0 Kudos
KavishGhime
Esri Contributor

Hi Jeremie,

You have given the methods to disable the zooming of map through mouse-scroll, but where to apply this method inside a web appbuilder application?

Thanks.

RobertScheitlin__GISP
MVP Emeritus

Ciprian,

   In the Edit widgets settings UI if you check "Disable Update Geometry" then you will not be able to move/scale/rotate the geometry, but you will still be able to delete and to update the attributes.

0 Kudos
CiprianLazar
New Contributor III

Hi,

That would be an option, but if a user makes a mistake when adding a feature, he would not be able to correct it. He would have to delete the feature and start all over again.

Can't I just disable the scale/move/rotate? It's too easy to accidentally move a feature and you might not even notice that you moved it.

Thank you.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ciprian,

   No, currently that is not a configurable option.

0 Kudos
CiprianLazar
New Contributor III

I was hoping for a programatically modification of the Editor widget in order to disable the scale/move/rotate. How and where should I interfere with esriBundle.toolbars.edit?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ciprian,

   I am not aware of a way to do that.

0 Kudos
KonstantinLapine
New Contributor

It appears moving can be disabled with the event handler:

myEditor.editToolbar.on('graphic-move', function (e) {
   throw('move is not allowed');
});

This does not work for rotating and scaling. Throwing inside 'rotate' and 'scale' event handlers does not prevent the changes from happening (in expected way, at least) and the event object does seem to provide means of stopping the event.

(Update) Just in case:

require([

   ...

   'esri/dijit/editing/Editor'

   ...

], function (

   ...

   Editor,

   ...

) {

   var myEditor;

   ...

   myEditor = new Editor(params, 'editor-element');

   ...

});

0 Kudos