Constrain center in ol.interaction.DragPan
This commit is contained in:
committed by
Frederic Junod
parent
92f7f14744
commit
2e395e4530
@@ -68,6 +68,7 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
];
|
||||
ol.coordinate.rotate(newCenter, view2DState.rotation);
|
||||
ol.coordinate.add(newCenter, this.startCenter);
|
||||
newCenter = view.constrainCenter(newCenter);
|
||||
map.requestRenderFrame();
|
||||
view.setCenter(newCenter);
|
||||
};
|
||||
@@ -95,6 +96,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
|
||||
centerpx[0] - distance * Math.cos(angle),
|
||||
centerpx[1] - distance * Math.sin(angle)
|
||||
]);
|
||||
dest = view.constrainCenter(dest);
|
||||
view.setCenter(dest);
|
||||
}
|
||||
map.requestRenderFrame();
|
||||
|
||||
Reference in New Issue
Block a user