|
|
@@ -209,8 +209,10 @@ define([
|
|
|
|
|
|
// canvas.width = parseFloat(svgDom.getAttribute('width')); // * pixelRatio
|
|
|
// canvas.height = parseFloat(svgDom.getAttribute('height')); // * pixelRatio
|
|
|
- canvas.width = 500;
|
|
|
- canvas.height = 500;
|
|
|
+ // canvas.width = 500
|
|
|
+ // canvas.height = 500
|
|
|
+ canvas.width = option.width
|
|
|
+ canvas.height = option.height
|
|
|
img.src = path;
|
|
|
img.onload = function () {
|
|
|
// 增加底色
|
|
|
@@ -273,13 +275,27 @@ define([
|
|
|
var guid = "VECTOR--" + options.layerInfo.id
|
|
|
let img = null;
|
|
|
if (style.point) {
|
|
|
- // 获取svg
|
|
|
- let svg = getAndSetSVGElement(style.point.photo, style.point.color)
|
|
|
- // console.log(svg)
|
|
|
- img = await svgToImg(svg);
|
|
|
- // img = await export2Base64Img(img, "", {
|
|
|
- // background: "#ffffff00"
|
|
|
- // });
|
|
|
+ if (style.point.photo.indexOf(".svg") > -1) {
|
|
|
+ // 获取svg
|
|
|
+ let svg = getAndSetSVGElement(style.point.photo, style.point.color)
|
|
|
+ // console.log(svg)
|
|
|
+ img = await svgToImg(svg);
|
|
|
+ if (style.point.photo.indexOf("coordinate") == -1) {
|
|
|
+ img = await export2Base64Img(img, "", {
|
|
|
+ background: "#ffffff00",
|
|
|
+ width: 200,
|
|
|
+ height: 200
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ img = await export2Base64Img(img, "", {
|
|
|
+ background: "#ffffff00",
|
|
|
+ width: 500,
|
|
|
+ height: 500
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ img = style.point.photo;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Cesium.GeoJsonDataSource.load(options.geo).then(
|
|
|
@@ -305,8 +321,8 @@ define([
|
|
|
// })
|
|
|
entity.billboard = new Cesium.BillboardGraphics({
|
|
|
image: img,
|
|
|
- width: 50,
|
|
|
- height: 50,
|
|
|
+ width: 28,
|
|
|
+ height: 28,
|
|
|
pixelOffset: new Cesium.Cartesian2(0, -25),
|
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
|
// scaleByDistance: new Cesium.NearFarScalar(10000, 1, 20000, 0.75),
|
|
|
@@ -317,11 +333,28 @@ define([
|
|
|
entity.polyline.material = Cesium.Color.fromCssColorString(style.polyline.color).withAlpha(style.polyline.alpha); // 颜色
|
|
|
}
|
|
|
if (entity.polygon) {
|
|
|
- entity.polygon.height = 0.2;
|
|
|
+ entity.polygon.height = 0;
|
|
|
entity.polygon.outline = true; // 边框是否显示
|
|
|
entity.polygon.outlineColor = Cesium.Color.fromCssColorString(style.polygon.outerColor); // 边框颜色
|
|
|
entity.polygon.outlineWidth = style.polygon.outerWidth; // 边框宽度
|
|
|
entity.polygon.material = Cesium.Color.fromCssColorString(style.polygon.innerColor).withAlpha(style.polygon.alpha);// 填充色
|
|
|
+
|
|
|
+ // entity.polyline = new Cesium.PolylineGraphics({
|
|
|
+ // position: entity.polygon.hierarchy.getValue().positions.concat([]),
|
|
|
+ // width: style.polygon.outerWidth,
|
|
|
+ // material: Cesium.Color.fromCssColorString(style.polygon.outerColor), // 颜色
|
|
|
+ // });
|
|
|
+
|
|
|
+ let outline = map3DViewer.map.entities.add({
|
|
|
+ name: "线",
|
|
|
+ polyline: {
|
|
|
+ //经纬度数组转世界坐标,带高度的话是fromDegreesArrayHeights
|
|
|
+ positions: entity.polygon.hierarchy.getValue().positions.concat([]),
|
|
|
+ width: style.polygon.outerWidth,
|
|
|
+ material: Cesium.Color.fromCssColorString(style.polygon.outerColor),
|
|
|
+ }
|
|
|
+ });
|
|
|
+ entity.outline = outline;
|
|
|
}
|
|
|
entity.layerId = guid
|
|
|
entity.mod = "vectorMod"
|
|
|
@@ -338,7 +371,15 @@ define([
|
|
|
};
|
|
|
|
|
|
function removeVECTOR(options) {
|
|
|
- map3DViewer.map.dataSources.remove(map3DViewer.map.dataSources.getByName(options.guid)[0]);
|
|
|
+ let dataSource = map3DViewer.map.dataSources.getByName(options.guid)[0]
|
|
|
+ var entities = dataSource.entities.values;
|
|
|
+ for (var i = 0; i < entities.length; i++) {
|
|
|
+ var entity = entities[i];
|
|
|
+ if (entity.polygon) {
|
|
|
+ map3DViewer.map.entities.remove(entity.outline);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map3DViewer.map.dataSources.remove(dataSource);
|
|
|
delete modValue.VECTOR[options.guid];
|
|
|
delete modValue.VECTOR[options.guid + "_extent"];
|
|
|
if (Object.getOwnPropertyNames(modValue.VECTOR).length == 0) {
|