我在用角度 openlayers 指令 https://github.com/tombatossals/angular-openlayers-directive,我想获取双击点的坐标。
类似的问题:
将点转换为经纬度 https://stackoverflow.com/questions/26967638/convert-point-to-lat-lon
但我想在 angularjs 中使用它。
你应该看看这个例子:http://tombatossals.github.io/angular-openlayers-directive/examples/080-events-propagation-example.html http://tombatossals.github.io/angular-openlayers-directive/examples/080-events-propagation-example.html。它展示了如何找到鼠标悬停的经纬度坐标。另外,这是我制作的一个小提琴,展示了如何扩展它以进行双击:http://jsfiddle.net/anushamc/6q2az5xz/ http://jsfiddle.net/anushamc/6q2az5xz/。简而言之,您需要通过将其包含在默认值中来侦听地图上的事件,例如:
defaults: {
events: {
map: ['singleclick', 'pointermove', 'dblclick']
}
}
and
<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
}
}
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)