|
@@ -91,6 +91,8 @@ export class olMap {
|
|
|
private carLayer;
|
|
|
private carFeature;
|
|
|
private traceFeature;
|
|
|
+ // 自定义绘制结束调用方法
|
|
|
+ private drawEndMethod;
|
|
|
|
|
|
constructor(options) {
|
|
|
this.options = options;
|
|
@@ -321,6 +323,7 @@ export class olMap {
|
|
|
marker: 'Point',
|
|
|
text: 'Point'
|
|
|
};
|
|
|
+ debugger
|
|
|
const data = getRgba(newOptions.color);
|
|
|
let geometryFunction = null;
|
|
|
if (newOptions.graphicsType === 'rectangle') {
|
|
@@ -700,19 +703,19 @@ export class olMap {
|
|
|
})
|
|
|
});
|
|
|
this.map.addLayer(this.maskLayer2);
|
|
|
- // this.maskLayer = new VectorLayer({
|
|
|
- // source: new VectorSource(),
|
|
|
- // style: new Style({
|
|
|
- // fill: new Fill({
|
|
|
- // color: options.fillColor ? options.fillColor : 'rgba(16, 36, 59, 0.65)'
|
|
|
- // }),
|
|
|
- // stroke: new Stroke({
|
|
|
- // color: options.strokeColor ? options.strokeColor : 'rgba(38, 138, 185, 1)',
|
|
|
- // width: 2
|
|
|
- // })
|
|
|
- // }),
|
|
|
- // zIndex: options.zIndex ? options.zIndex : 99
|
|
|
- // });
|
|
|
+ this.maskLayer = new VectorLayer({
|
|
|
+ source: new VectorSource(),
|
|
|
+ style: new Style({
|
|
|
+ fill: new Fill({
|
|
|
+ color: options.fillColor ? options.fillColor : 'rgba(16, 36, 59, 0.65)'
|
|
|
+ }),
|
|
|
+ stroke: new Stroke({
|
|
|
+ color: options.strokeColor ? options.strokeColor : 'rgba(38, 138, 185, 1)',
|
|
|
+ width: 2
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ zIndex: options.zIndex ? options.zIndex : 99
|
|
|
+ });
|
|
|
// // 合并区边界
|
|
|
// const format = new GeoJSON();
|
|
|
// const data2 = mergeGeoJsonPolygons(json);
|
|
@@ -988,8 +991,9 @@ export class olMap {
|
|
|
const icon = new Icon({
|
|
|
crossOrigin: 'anonymous',
|
|
|
src: carImg,
|
|
|
- width: 26,
|
|
|
- height: 52,
|
|
|
+ width: 13,
|
|
|
+ height: 26,
|
|
|
+ anchor: [0.5, 0.5],
|
|
|
rotation: angle
|
|
|
});
|
|
|
this.carFeature.setStyle(
|
|
@@ -1005,7 +1009,7 @@ export class olMap {
|
|
|
source: source,
|
|
|
style: new Style({
|
|
|
stroke: new Stroke({
|
|
|
- color: 'rgb(37,232,142)',
|
|
|
+ color: '#AF5',
|
|
|
width: 5
|
|
|
})
|
|
|
})
|
|
@@ -1046,6 +1050,7 @@ export class olMap {
|
|
|
// 触发地图渲染
|
|
|
const geo = this.carFeature.getGeometry().clone();
|
|
|
this.carFeature.setGeometry(geo);
|
|
|
+ return [this.carLayer];
|
|
|
}
|
|
|
drawData(data) {
|
|
|
const res = [];
|
|
@@ -1108,11 +1113,11 @@ export class olMap {
|
|
|
// 图片加载完成后,可以访问其 width 和 height 属性
|
|
|
const width = img.width;
|
|
|
const height = img.height;
|
|
|
+ // const anchor = [9 / width, 1 - (9 / height)];
|
|
|
+ const anchor = [9, 9];
|
|
|
const style = new Style({
|
|
|
image: new Icon({
|
|
|
- anchor: [0.5, 0.5],
|
|
|
- anchorXUnits: 'fraction',
|
|
|
- anchorYUnits: 'pixels',
|
|
|
+ anchor: [0.5, 1],
|
|
|
src: item.icon,
|
|
|
size: [width, height],
|
|
|
scale: !!item.size[0] ? item.size[0] / width : 1
|
|
@@ -1149,4 +1154,7 @@ export class olMap {
|
|
|
getMouseTool() {
|
|
|
return this.drawTool;
|
|
|
}
|
|
|
+ setDrawEndMethod(newMethod) {
|
|
|
+ this.drawEndMethod = newMethod;
|
|
|
+ }
|
|
|
}
|