In the ArcGIS API for JavaScript 4.3, when looking at a map on a mobile device, is it possible to configure the map or map view to not rotate when pinching to zoom?
Solved! Go to Solution.
Matt,
you can use:
// Disables map rotation
view.constraints = {
rotationEnabled: false
};
For your specific use case you would have to add the constraint using the view pointer-down event and then on the pointer-up you could remove the constraint.
Matt,
you can use:
// Disables map rotation
view.constraints = {
rotationEnabled: false
};
For your specific use case you would have to add the constraint using the view pointer-down event and then on the pointer-up you could remove the constraint.
Robert,
That's perfect - thanks!
Hi all,
I am also attempting to prevent map rotation on pinch zoom with JSAPI v4.3.
Finding that any use of the rotationEnabled constraint kills pinch zooming completely, which seems odd.
Tried using rotationEnabled constraint property on creation of the MapView, also attempted Robert's suggestion of adding/removing constraint on view pointer-down/pointer-up events.
view.on('pointer-down', function(){
view.constraints = {
rotationEnabled: false
};
});
view.on('pointer-up', function(){
view.constraints = {
rotationEnabled: true
};
});
Any ideas on why the rotationEnabled constraint would prevent pinch zooming?
Thanks!
Jared
I think when you assign the new object you are clearing out the default constraints.
However, I am getting the same behavior (pinch zooming disabled) even when I do
Hi All,
I have the same problem since the version 4.3 of JSAPI, the pinch to zoom doesn't work if you disable the rotation option.
My workaround for the moment is :
1) Active rotationEnabled à true
constraints : { rotationEnabled: true }
2) set rotation=0 for each pointer-up event
var view = new MapView(*****);view.on('pointer-up', function(){ view.rotation = 0; });
It works on mobile. It would be nice if this option rotation will be separate from the zoom...
BR,
Stéphane
As an update to this, I was looking for a way to disable user rotation while still setting a rotation amount at the view level.
Working with Tech Support, credit to Mayur, we created a watch function where the if a user tries to rotate the map is returned to the view setting. This has the effect of essentially disabling rotation.
// to watch any change in "rotation" property of view.
view.watch("rotation", function(norotate) {
console.log(norotate);
view.rotation = 289 // if this is hit set the rotation back to 289
}),
You can see result here, https://gis.greenvillesc.gov/imaginefestival/index.html
Scott