|
@@ -91,6 +91,8 @@ export class olMap {
|
|
|
private carLayer;
|
|
|
private carFeature;
|
|
|
private traceFeature;
|
|
|
+ // 自定义绘制结束调用方法
|
|
|
+ private drawEndMethod;
|
|
|
|
|
|
constructor(options) {
|
|
|
this.options = options;
|
|
@@ -700,19 +702,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 +990,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 +1008,7 @@ export class olMap {
|
|
|
source: source,
|
|
|
style: new Style({
|
|
|
stroke: new Stroke({
|
|
|
- color: 'rgb(37,232,142)',
|
|
|
+ color: '#AF5',
|
|
|
width: 5
|
|
|
})
|
|
|
})
|
|
@@ -1046,6 +1049,7 @@ export class olMap {
|
|
|
// 触发地图渲染
|
|
|
const geo = this.carFeature.getGeometry().clone();
|
|
|
this.carFeature.setGeometry(geo);
|
|
|
+ return [this.carLayer];
|
|
|
}
|
|
|
drawData(data) {
|
|
|
const res = [];
|
|
@@ -1110,9 +1114,7 @@ export class olMap {
|
|
|
const height = img.height;
|
|
|
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 +1151,7 @@ export class olMap {
|
|
|
getMouseTool() {
|
|
|
return this.drawTool;
|
|
|
}
|
|
|
+ setDrawEndMethod(newMethod) {
|
|
|
+ this.drawEndMethod = newMethod;
|
|
|
+ }
|
|
|
}
|