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
Hi,
In map, you have methods to disable navigation :
Map | API Reference | ArcGIS API for JavaScript
disableClickRecenter() | None | Disallows clicking on a map to center it. |
disableDoubleClickZoom() | None | Disallows double clicking on a map to zoom in a level and center the map. |
disableKeyboardNavigation() | None | Disallows panning and zooming using the keyboard. |
disableMapNavigation() | None | Disallows all map navigation except the slider and pan arrows. |
disablePan() | None | Disallows panning a map using the mouse. |
disableRubberBandZoom() | None | Disallows zooming in or out on a map using a bounding box. |
disableScrollWheelZoom() | None | Disallows zooming in or out on a map using the mouse scroll wheel. |
disableShiftDoubleClickZoom() | None | Disallows shift double clicking on a map to zoom in a level and center the map. |
hidePanArrows() | None | Hides the pan arrows from the map. |
hideZoomSlider() | None | Hides the zoom slider from the map. |
https://developers.arcgis.com/javascript/jsapi/map.html#hidezoomslider
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.
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.
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.
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.
Ciprian,
No, currently that is not a configurable option.
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?
Ciprian,
I am not aware of a way to do that.
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');
...
});