浏览代码

修改叫号插件

wandequan 2 年之前
父节点
当前提交
a95531718c
共有 2 个文件被更改,包括 52 次插入4 次删除
  1. 48 0
      public/static/plugins/js/cesiumPlugins/materialDynamicImage_origin.js
  2. 4 4
      src/components2/MainMap.vue

+ 48 - 0
public/static/plugins/js/cesiumPlugins/materialDynamicImage_origin.js

@@ -35,6 +35,54 @@
         });
     }
 
+
+    function drawText(obj) {
+        console.log('渲染文字')
+        this.ctx.save(); this.ctx.setFillStyle(obj.color);
+        this.ctx.setFontSize(obj.size);
+        this.ctx.setTextAlign(obj.align);
+        this.ctx.setTextBaseline(obj.baseline);
+        if (obj.bold) {
+            console.log('字体加粗')
+            this.ctx.fillText(obj.text, obj.x, obj.y - 0.5);
+            this.ctx.fillText(obj.text, obj.x - 0.5, obj.y);
+        }
+        this.ctx.fillText(obj.text, obj.x, obj.y);
+        if (obj.bold) {
+            this.ctx.fillText(obj.text, obj.x, obj.y + 0.5);
+            this.ctx.fillText(obj.text, obj.x + 0.5, obj.y);
+        }
+        this.ctx.restore();
+    }
+    /**
+* 文本换行
+*
+* @param {Object} obj
+*/
+    function textWrap(obj) {
+        console.log('文本换行')
+        var td = Math.ceil(obj.width / (obj.size));
+        var tr = Math.ceil(obj.text.length / td);
+        for (var i = 0; i < tr; i++) {
+            var txt = {
+                x: obj.x,
+                y: obj.y + (i * obj.height),
+                color: obj.color,
+                size: obj.size,
+                align: obj.align,
+                baseline: obj.baseline,
+                text: obj.text.substring(i * td, (i + 1) * td),
+                bold: obj.bold
+            };
+            if (i < obj.line) {
+                if (i == obj.line - 1) {
+                    txt.text = txt.text.substring(0, txt.text.length - 3) + '......';
+                }
+                 this.drawText(txt);
+            }
+        }
+    }
+
     createDynamicImage.prototype.createTextImage = function () {
         var canvas = document.createElement('canvas');
         canvas.width = this.imageWidth || 1000;

+ 4 - 4
src/components2/MainMap.vue

@@ -156,8 +156,8 @@ export default {
     window.changeImage = this.changeImage;
     addImage(globalVariable.viewer, {
       arr: [
-        121.12273519090121, 31.153826679130416, 3.280499471365055,
-        121.12273833983032, 31.153813096263634, 3.281036567079009,
+        121.12273519090121, 31.153827313511016, 3.280499471365055,
+        121.12273815983032, 31.153814774429165, 3.281036567079009,
       ],
       minH: [2.807028457880749, 2.807028457880749],
     });
@@ -706,8 +706,8 @@ export default {
           canvasWidth: 500,
           canvasHeight: 200,
           period: 10,
-          text: "请18号前往14号服务台",
-          textStyle: "italic 40pt Calibri",
+          text: "税务综合受理",
+          textStyle: "normal bold 40pt 宋体",
         }).then((result) => {
           // let material = Cesium.Material.fromType("Image");
           // material.uniforms.image = result;