@extendz/extendz-openlayer
Version:
Extend UI Platform built on Angular Material
102 lines • 4.15 kB
JavaScript
/**
* Copyright 2018 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as ol from 'openlayers';
export var OpenLayerToolType;
(function (OpenLayerToolType) {
OpenLayerToolType[OpenLayerToolType["POINT"] = 0] = "POINT";
OpenLayerToolType[OpenLayerToolType["POLYGON"] = 1] = "POLYGON";
})(OpenLayerToolType || (OpenLayerToolType = {}));
export var PointToolType;
(function (PointToolType) {
PointToolType[PointToolType["CAR"] = 0] = "CAR";
PointToolType[PointToolType["PRODUCTION_CAR"] = 1] = "PRODUCTION_CAR";
})(PointToolType || (PointToolType = {}));
export var PolygonToolType;
(function (PolygonToolType) {
PolygonToolType[PolygonToolType["CONCENTRATES"] = 0] = "CONCENTRATES";
PolygonToolType[PolygonToolType["STOCK"] = 1] = "STOCK";
})(PolygonToolType || (PolygonToolType = {}));
export var MoveToolType;
(function (MoveToolType) {
MoveToolType[MoveToolType["MOVE"] = 0] = "MOVE";
})(MoveToolType || (MoveToolType = {}));
var OpenLayerTool = /** @class */ (function () {
function OpenLayerTool() {
}
OpenLayerTool.prototype.getSource = function () {
return new ol.source.Vector({ wrapX: true });
}; // End getSource ()
OpenLayerTool.prototype.getVectorLayer = function (source, color) {
return new ol.layer.Vector({
source: source,
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 3,
fill: new ol.style.Fill({
color: color
})
})
})
});
}; // End _getVectorLayer()
OpenLayerTool.prototype.getStyle = function (color) {
return new ol.style.Style({
image: new ol.style.Circle({
fill: new ol.style.Fill({ color: 'rgba(0,0,0,0.0)' }),
stroke: new ol.style.Stroke({ color: color, width: 3 }),
radius: 5
}),
fill: new ol.style.Fill({ color: color }),
stroke: new ol.style.Stroke({ color: color, width: 3 }),
});
}; // End _getMouseStyle()
OpenLayerTool.getBorderOnlyStyle = function () {
return new ol.style.Style({
fill: new ol.style.Fill({ color: 'rgba(0,0,0,0.0)' }),
stroke: new ol.style.Stroke({ color: 'rgba(204,255,0,0.42)', width: 1 }),
});
};
OpenLayerTool.prototype.createDraw = function (source, style, features, clickTolerance, type) {
return new ol.interaction.Draw({
clickTolerance: 1000,
features: features,
type: 'Polygon',
source: source,
style: style,
/**
* If the middle/right mouse button is presseed then the draw event is blocked.It will trigger the Drag Pan/ finish draw event.
*/
condition: function (event) {
var originalEvent = event.originalEvent;
if (originalEvent.button == 1 || originalEvent.button == 21)
return false;
return true;
},
/**
* On right click the draw should be stoped.
*/
finishCondition: function (event) {
var originalEvent = event.originalEvent;
if (originalEvent.button == 0)
return true;
return false;
}
});
}; // End createDraw()
return OpenLayerTool;
}()); // End class OpenLayerTool
export { OpenLayerTool };
//# sourceMappingURL=open-layer-tool.js.map