SmartIT_Extensions/BMC/smart-it-full/scripts/app/location/poi-infobubble.js

47 lines
1.8 KiB
JavaScript

"use strict";
(function () {
'use strict';
angular.module('locationModule')
.directive('poiInfoBubble', function () {
return {
restrict: 'AE',
template: '<div><div class="location-map__info-bubble">' +
'<div class="location-map__info-bubble_poi-details">' +
'<div class="location-map__info-bubble_poi-name">{{poi.name}}</div>' +
'<div class="location-map__info-bubble_poi-type">{{poi.type.name}}</div>' +
'</div></div><div class="location-map__info-bubble_anchor"></div></div>',
replace: true,
scope: {
poi: '=parent'
},
link: function (scope, $element) {
var map = scope.poi.marker.map;
var infoBubble = new bmcMaps.InfoBubble({
content: $element[0],
position: scope.poi.marker.position,
shadowStyle: 0,
borderWidth: 0,
padding: 0,
backgroundColor: 'transparent',
borderRadius: 4,
arrowSize: 0,
hideCloseButton: true,
arrowPosition: 50,
arrowStyle: 0
});
scope.poi.infoBubble = infoBubble;
scope.poi.infoBubble.open(map);
scope.poi.marker.setVisible(false);
function handleMapClick() {
scope.poi.infoBubble.close();
scope.poi.marker.setVisible(true);
}
bmcMaps.event.addListener(map, 'click', handleMapClick);
scope.$on('$destroy', function () {
bmcMaps.event.clearInstanceListeners(map);
});
}
};
});
}());