|
24 | 24 | enableLinks: '=', |
25 | 25 |
|
26 | 26 | // parent callbacks |
27 | | - parentSingleClick: '&singleClick' |
| 27 | + parentSingleClick: '&singleClick', |
| 28 | + parentDoubleClick: '&doubleClick' |
28 | 29 | }, |
29 | 30 | templateUrl: '/templates/detail-map.html', |
30 | 31 | controller: 'MLOlDetailMapController', |
|
54 | 55 | }); |
55 | 56 |
|
56 | 57 | $scope.$on('openlayers.map.singleclick', function(event, data) { |
| 58 | + if (data.event.map.hasFeatureAtPixel(data.event.pixel)) { |
| 59 | + data.event.map.forEachFeatureAtPixel(data.event.pixel, function (feature, layer) { |
| 60 | + $scope.$apply(function() { |
| 61 | + if ($scope.parentSingleClick) { |
| 62 | + $scope.parentSingleClick({ 'feature': feature }); |
| 63 | + } |
| 64 | + |
| 65 | + // if (feature.get('metadata')) { |
| 66 | + // ctrl.mapItemSelected = feature.get('metadata'); |
| 67 | + // } |
| 68 | + }); |
| 69 | + }); |
| 70 | + } |
| 71 | + else { |
| 72 | + $scope.$apply(function() { |
| 73 | + ctrl.mapItemSelected = null; |
| 74 | + }); |
| 75 | + } |
| 76 | + }); |
| 77 | + |
| 78 | + $scope.$on('openlayers.map.dblclick', function(event, data) { |
57 | 79 | data.event.map.forEachFeatureAtPixel(data.event.pixel, function (feature, layer) { |
58 | | - var featureUri = feature.get('uri'); |
59 | 80 | $scope.$apply(function() { |
60 | | - if ($scope.parentSingleClick) { |
61 | | - $scope.parentSingleClick({ 'featureUri': featureUri }); |
| 81 | + if ($scope.parentDoubleClick) { |
| 82 | + $scope.parentDoubleClick({ 'feature': feature }); |
62 | 83 | } |
63 | 84 |
|
64 | 85 | if ($scope.enableLinks) { |
|
384 | 405 | }; |
385 | 406 |
|
386 | 407 | var createLineStyle = function(feature, resolution) { |
387 | | - // var geometry = feature.getGeometry(); |
| 408 | + var geometry = feature.getGeometry(); |
388 | 409 | var styles = [ |
389 | 410 | new ol.style.Style({ |
390 | 411 | stroke: new ol.style.Stroke({color: 'black', width: 3}), |
391 | 412 | text: createTextStyle(feature.get('name'), 'black') |
392 | 413 | }) |
393 | 414 | ]; |
394 | 415 |
|
395 | | - // geometry.forEachSegment(function(start, end) { |
396 | | - // var dx = end[0] - start[0]; |
397 | | - // var dy = end[1] - start[1]; |
398 | | - // var rotation = Math.atan2(dy, dx); |
399 | | - // // arrows |
400 | | - // styles.push(new ol.style.Style({ |
401 | | - // geometry: new ol.geom.Point(end), |
402 | | - // image: new ol.style.Icon({ |
403 | | - // src: 'images/arrow-black.png', |
404 | | - // anchor: [1.5, 0.5], |
405 | | - // rotateWithView: false, |
406 | | - // rotation: -rotation |
407 | | - // }) |
408 | | - // })); |
409 | | - // }); |
| 416 | + geometry.forEachSegment(function(start, end) { |
| 417 | + var dx = end[0] - start[0]; |
| 418 | + var dy = end[1] - start[1]; |
| 419 | + var rotation = Math.atan2(dy, dx); |
| 420 | + // arrows |
| 421 | + styles.push(new ol.style.Style({ |
| 422 | + geometry: new ol.geom.Point(end), |
| 423 | + image: new ol.style.Icon({ |
| 424 | + src: 'images/arrow-black.png', |
| 425 | + anchor: [1.5, 0.5], |
| 426 | + rotateWithView: false, |
| 427 | + rotation: -rotation |
| 428 | + }) |
| 429 | + })); |
| 430 | + }); |
410 | 431 |
|
411 | 432 | return styles; |
412 | 433 | }; |
|
489 | 510 | }, |
490 | 511 | defaults: { |
491 | 512 | interactions: { |
492 | | - mouseWheelZoom: true |
| 513 | + mouseWheelZoom: true, |
| 514 | + doubleClickZoom: false |
493 | 515 | }, |
494 | 516 | controls: { |
495 | 517 | zoom: true, |
496 | 518 | rotate: false, |
497 | 519 | attribution: false |
498 | 520 | }, |
499 | 521 | events: { |
500 | | - map: ['singleclick', 'moveend'] |
| 522 | + map: ['singleclick', 'dblclick', 'moveend'] |
501 | 523 | } |
502 | 524 | }, |
503 | 525 | baseMap: { |
|
0 commit comments