答案 0 :(得分:0)
您应该查看此示例:http://tombatossals.github.io/angular-openlayers-directive/examples/080-events-propagation-example.html。它显示了如何找到鼠标悬停的lat-long坐标。另外,这里有一个小提琴,展示了如何将其扩展为双击:http://jsfiddle.net/anushamc/6q2az5xz/。简而言之,您需要通过将其包含在默认值中来监听地图上的事件,例如:
defaults: {
events: {
map: ['singleclick', 'pointermove', 'dblclick']
}
}
和
<openlayers ol-defaults="defaults"></openlayers>
并在范围内包含openlayers.map.dblclick的侦听器。
$scope.$on('openlayers.map.dblclick', function(event, data) {
$scope.$apply(function() {
if ($scope.projection === data.projection) {
$scope.mousedoubleclickposition = data.coord;
} else {
var p = ol.proj.transform([data.coord[0], data.coord[1]], data.projection, $scope.projection);
$scope.mousedoubleclickposition = {
lat: p[1],
lon: p[0],
projection: $scope.projection
}
}
});
});