Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue编写动态绘制只能绘制一次,点击其他图形绘制报错 #29

Open
18465139686 opened this issue Dec 21, 2021 · 1 comment

Comments

@18465139686
Copy link

第一次点击一个图形可以进行绘制,但是当你第二次点击其他图形绘制时就会报错???

一、当第二次点击其他图形绘制时,就会报以下错:
VM32937:1 Uncaught ReferenceError: RuntimeError is not defined at Tl.add (eval at <anonymous> (Cesium.js:1), <anonymous>:1:3881794) at Plotting.InitPlot (plotting.js?159d:26) at new Plotting (plotting.js?159d:15) at o.imageClick (index.vue?0dbc:234) at click (index.vue?f684:31) at i (vue.min.js:6) at HTMLImageElement.Rr.t._withTask.o._withTask (vue.min.js:6)
二、这是vue页面调用plotting.js文件实现的:
method:{ // 绘制面板 imageClick(val) { var plotting = new Plotting(window.viewer); if (plotting) { plotting.DrawCellClick(val); } }, }

三、这是我提取出来的文件和开源集成的:
`class Plotting {
constructor(viewer) {
this.viewer = viewer;
this.host = 'http://support.supermap.com.cn:8090';
this.cesium = Cesium;
this.scene = viewer.scene;
this.scene.globe.depthTestAgainstTerrain = false;
this.serverUrl = this.host + '/iserver/services/plot-jingyong/rest/plot';
this.plotting;
this.plottingLayer;
this.plotEditControl;
this.plotDrawControl;
this.plotPanel;
this.stylePanel;
this.InitPlot();
}
InitPlot() {
var self = this;
if (!this.viewer) {
return;
}
self.plottingLayer = new self.cesium.PlottingLayer(
self.scene,
'plottingLayer',
);
self.scene.plotLayers.add(self.plottingLayer);

self.plotEditControl = new self.cesium.PlotEditControl(
  self.scene,
  self.plottingLayer,
); //编辑控件
self.plotDrawControl = new self.cesium.PlotDrawControl(
  self.scene,
  self.plottingLayer,
); //绘制控件 

self.plotDrawControl.drawControlEndEvent.addEventListener(()=>{
  //标绘结束,激活编辑控件

  self.plotEditControl.activate();
});

self.plotting = self.cesium.Plotting.getInstance(
  self.serverUrl,
  self.scene,
);
//标绘面板
// initPlotPanel("plotPanel", serverUrl, plotDrawControl, plotEditControl, plotting);
// 属性面板
// self.stylePanel = new StylePanel(
//   'stylePanel',
//   self.plotEditControl,
//   self.plotting,
// );

}
DrawCellClick(drawCellparam) {
console.log(drawCellparam,'drawcell');
console.log(this.plotDrawControl,'plotDraw');
var self = this;
if (self.plotDrawControl !== null) {
self.plotDrawControl.deactivate();
self.plotDrawControl.libID = drawCellparam.libID;
self.plotDrawControl.code = drawCellparam.symbolCode;

  //设置标号默认的模型路径
  self.plotDrawControl.drawFinishEvent.addEventListener(function (geo) {
    if (geo.symbolType === SuperMap.Plot.SymbolType.DOTSYMBOL) {
      geo.modelPath = './SampleData/plot/Cesium_Air.gltf';
      geo.picturePath = './SampleData/plot/blupin.png';
    }
  });
  self.plotDrawControl.serverUrl = self.serverUrl;

  self.plotDrawControl.activate();
  if (undefined !== self.plotEditControl) {
    self.plotEditControl.deactivate();
  }
}

}
//删除指定标号
deleteSeleGeo() {
var self = this;
self.plottingLayer.removeGeoGraphicObject(
self.plottingLayer.selectedFeature,
);
}
//获取属性面板GridDom
getGridDomObdect() {
var self = this;
return self.stylePanel.getDomObject();
}

// // 想要通过该方法来暴露x
// showX () {
// return this.x
// }
}
export default Plotting;
`

@18465139686
Copy link
Author

这个地址可以查看问题详情!
http://ask.supermap.com/103115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant