企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
设计页 搜索 case"surface\_lng\_lats": 如图所示: ![](https://img.kancloud.cn/7a/e3/7ae371120f00d6d05aa9d690201e99e8_1339x590.png) ``` case "surface_lng_lats": var earlyWarning = []; if (component.config.mapSurfaceConfig != null && component.config.mapSurfaceConfig[layer.id] != null && component.config.mapSurfaceConfig[layer.id].length > 0) { for (var l in component.config.mapSurfaceConfig[layer.id]) { var colorValues = component.config.mapSurfaceConfig[layer.id][l]; earlyWarning.push({ min:getCaption(component.config[colorValues.valuesBind],0), max:getCaption(component.config[colorValues.valuesBind],1), color:component.config[colorValues.colorBind] }) } } console.log(earlyWarning) for (var i in data) { var lngLats = data[i][dimensions[dimensions.length - 1].name]; var weight = 0; if (measures != null && measures.length > 0) { weight = data[i][measures[measures.length - 1].name]; } else { weight = 1; } var color = layer.mapFillColor; // if(weight>=1000&&weight<=2000){ // var color = '#ff8800' // } // if(weight>=2000&&weight<=3000){ // var color = 'rgba(73, 237, 117, 1)' // } for(var j = 0;j<earlyWarning.length;j++){ if(weight>=earlyWarning[j].min&&weight<=earlyWarning[j].max){ color = earlyWarning[j].color } } if (!VSUtils.isEmpty(lngLats)) { var arr = lngLats.split(","); var lngLatArr = []; for(var l in arr) { if (l % 2 == 1) { lngLatArr.push([parseFloat(arr[l -1]), parseFloat(arr[l])]); } } geojson.features.push({ type: "Feature", properties: { weight: weight, ethnicity:color }, geometry: { type: "MultiPolygon", coordinates: [[lngLatArr]] } }); } } break; ``` 搜索 surface\_lng\_lats" === layer.columnType 替换里面的代码 如图 ![](https://img.kancloud.cn/de/1b/de1bbb717f9645cb98eab955c78f95f6_1312x589.png) ``` if (map.getLayer(layerId) == undefined) { map.addSource(sourceId, { 'type': 'geojson', 'data': geojson }); map.addLayer({ 'id': layerId, 'source': sourceId, 'type': 'fill', 'paint': { 'fill-color': ["get", 'ethnicity'], 'fill-outline-color': layer.mapBorderColor, 'fill-opacity': parseInt(layer.mapOpactiy)/100, } }); } else { map.getSource(sourceId).setData(geojson); map.setPaintProperty(layerId, 'fill-color', ["get", 'ethnicity']); map.setPaintProperty(layerId, 'fill-outline-color', layer.mapBorderColor); map.setPaintProperty(layerId, 'fill-opacity', parseInt(layer.mapOpactiy)/100); } ``` 设置面板 搜索:描边颜色 在下面添加以下代码 如图:![](https://img.kancloud.cn/ad/f5/adf5a770be8109638e5f09545bada503_1152x868.png) ``` var linearColor = "linearColor"; var buildColorValueItem = function() { var groupIndex = component.config.groupIndex; var item = { index: groupIndex, valuesBind: "map_linear_values_" + groupIndex, colorBind: "map_linear_color_" + groupIndex } if (component.config.mapSurfaceConfig == null) component.config.mapSurfaceConfig = {}; if (component.config.mapSurfaceConfig[component.config.currentedLayerId] == null) component.config.mapSurfaceConfig[component.config.currentedLayerId] = []; component.config.mapSurfaceConfig[component.config.currentedLayerId].push(item); component.config.groupIndex++; return item; }; var buildColorValueConfig = function(temp) { var itemConfig = { title: vsLang.value, type: linearColor, disabled: false, item: temp, bind: { values: temp.valuesBind, color: temp.colorBind }, remove: function(item) { var index = layerConfig.elements.indexOf(item); layerConfig.elements.splice(index, 1); if (component.config.mapSurfaceConfig != null && component.config.mapSurfaceConfig[component.config.currentedLayerId] != null) { var indexItem = component.config.mapSurfaceConfig[component.config.currentedLayerId].indexOf(item.item); component.config.mapSurfaceConfig[component.config.currentedLayerId].splice(indexItem, 1); } } }; var indexEnd = layerConfig.elements.indexOf(linearColorConfigEnd); layerConfig.elements.splice(indexEnd, 0, itemConfig); }; layerConfig.elements.push( { title: '增加值域', type: "button", btnClass: "btn-primary", onClick: function(item) { var temp = buildColorValueItem(); buildColorValueConfig(temp); } }); layerConfig.elements.push(linearColorConfigEnd); if (component.config.mapSurfaceConfig != null && component.config.mapSurfaceConfig[component.config.currentedLayerId] != null) { for (var c in component.config.mapSurfaceConfig[component.config.currentedLayerId]) { buildColorValueConfig(component.config.mapSurfaceConfig[component.config.currentedLayerId][c]); } } ``` 分享页: 搜索 case"surface\_lng\_lats": 如图所示: ![](https://img.kancloud.cn/7a/e3/7ae371120f00d6d05aa9d690201e99e8_1339x590.png) ``` case "surface_lng_lats": var earlyWarning = []; if (component.config.mapSurfaceConfig != null && component.config.mapSurfaceConfig[layer.id] != null && component.config.mapSurfaceConfig[layer.id].length > 0) { for (var l in component.config.mapSurfaceConfig[layer.id]) { var colorValues = component.config.mapSurfaceConfig[layer.id][l]; earlyWarning.push({ min:getCaption(component.config[colorValues.valuesBind],0), max:getCaption(component.config[colorValues.valuesBind],1), color:component.config[colorValues.colorBind] }) } } console.log(earlyWarning) for (var i in data) { var lngLats = data[i][dimensions[dimensions.length - 1].name]; var weight = 0; if (measures != null && measures.length > 0) { weight = data[i][measures[measures.length - 1].name]; } else { weight = 1; } var color = layer.mapFillColor; // if(weight>=1000&&weight<=2000){ // var color = '#ff8800' // } // if(weight>=2000&&weight<=3000){ // var color = 'rgba(73, 237, 117, 1)' // } for(var j = 0;j<earlyWarning.length;j++){ if(weight>=earlyWarning[j].min&&weight<=earlyWarning[j].max){ color = earlyWarning[j].color } } if (!VSUtils.isEmpty(lngLats)) { var arr = lngLats.split(","); var lngLatArr = []; for(var l in arr) { if (l % 2 == 1) { lngLatArr.push([parseFloat(arr[l -1]), parseFloat(arr[l])]); } } geojson.features.push({ type: "Feature", properties: { weight: weight, ethnicity:color }, geometry: { type: "MultiPolygon", coordinates: [[lngLatArr]] } }); } } break; ``` 搜索 surface\_lng\_lats" === layer.columnType 替换里面的代码 如图 ![](https://img.kancloud.cn/de/1b/de1bbb717f9645cb98eab955c78f95f6_1312x589.png) ``` if (map.getLayer(layerId) == undefined) { map.addSource(sourceId, { 'type': 'geojson', 'data': geojson }); map.addLayer({ 'id': layerId, 'source': sourceId, 'type': 'fill', 'paint': { 'fill-color': ["get", 'ethnicity'], 'fill-outline-color': layer.mapBorderColor, 'fill-opacity': parseInt(layer.mapOpactiy)/100, } }); } else { map.getSource(sourceId).setData(geojson); map.setPaintProperty(layerId, 'fill-color', ["get", 'ethnicity']); map.setPaintProperty(layerId, 'fill-outline-color', layer.mapBorderColor); map.setPaintProperty(layerId, 'fill-opacity', parseInt(layer.mapOpactiy)/100); } ``` 最后的效果: ![](https://img.kancloud.cn/f1/71/f171dd9f27f43fb08a4b78b2b40b538c_1226x856.png)