There is a problem to set interaction for the map object in OpenLayers. I've used this code but it's not working:
var osmLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var interaction = new ol.interaction.DragRotateAndZoom();
var center = ol.proj.transform([51.34, 35.65], 'EPSG:4326', 'EPSG:3857');
var view = new ol.View({
center: center,
zoom: 10
});
var map = new ol.Map({
target: 'map',
layers: [osmLayer],
interactions: [interaction],
view: view
});
But when I use this template the interaction is just fine. what's wrong with first approach?
var map = new ol.Map({
target: 'map',
layers: [osmLayer],
view: view
});
map.addInteraction(interaction);