Merge pull request #5887 from felixveysseyre/interactive-overview-map
Interactive overview map
This commit is contained in:
@@ -239,3 +239,7 @@
|
|||||||
.ol-overviewmap-box {
|
.ol-overviewmap-box {
|
||||||
border: 2px dotted rgba(0,60,136,0.7);
|
border: 2px dotted rgba(0,60,136,0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ol-overviewmap .ol-overviewmap-box:hover {
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
@@ -148,6 +148,44 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
render: render,
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Interactive map */
|
||||||
|
|
||||||
|
var scope = this;
|
||||||
|
|
||||||
|
var overlay = this.boxOverlay_;
|
||||||
|
var overlayBox = this.boxOverlay_.getElement();
|
||||||
|
|
||||||
|
/* Functions definition */
|
||||||
|
|
||||||
|
var computeDesiredMousePosition = function(mousePosition) {
|
||||||
|
return {
|
||||||
|
clientX: mousePosition.clientX - (overlayBox.offsetWidth / 2),
|
||||||
|
clientY: mousePosition.clientY + (overlayBox.offsetHeight / 2)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var move = function(event) {
|
||||||
|
var coordinates = ovmap.getEventCoordinate(computeDesiredMousePosition(event));
|
||||||
|
|
||||||
|
overlay.setPosition(coordinates);
|
||||||
|
};
|
||||||
|
|
||||||
|
var endMoving = function(event) {
|
||||||
|
var coordinates = ovmap.getEventCoordinate(event);
|
||||||
|
|
||||||
|
scope.getMap().getView().setCenter(coordinates);
|
||||||
|
|
||||||
|
window.removeEventListener('mousemove', move);
|
||||||
|
window.removeEventListener('mouseup', endMoving);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Binding */
|
||||||
|
|
||||||
|
overlayBox.addEventListener('mousedown', function() {
|
||||||
|
window.addEventListener('mousemove', move);
|
||||||
|
window.addEventListener('mouseup', endMoving);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
ol.inherits(ol.control.OverviewMap, ol.control.Control);
|
ol.inherits(ol.control.OverviewMap, ol.control.Control);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user