🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
文件:D:\ireport365\ireport365.war\WEB-INF\classes\report-resource\design.js 搜索buildBaiduMapComponent 方法 整个替换 ``` var buildBaiduMapComponent = function (scope, element) { var component = scope.component; var mapDomId = "map_" + component.id; var html = []; html.push("<div style='height:100%;width:100%;'>"); html.push(" <div id='" + mapDomId + "' style='font-size:14px;height:100%;width:100%;'>"); html.push(" </div>"); html.push(" <div class='baidumap-control-bar' ng-show='component.config.showToolbar' id='controlBar' style='position:absolute;right:10px;bottom:10px;width:32px;height: 98px;'>"); html.push(" <div class='cbtn' id='locationBtn' style='padding-top:8px;'>"); html.push(" <i style='font-size:18px;' class='fa fa-crosshairs'></i>"); html.push(" </div>"); html.push(" <div class='cbtn' id='zoomInBtn' style='margin-top:5px;'>"); html.push(" <i class='fa fa-plus'></i>"); html.push(" </div>"); html.push(" <div class='cbtn' id='zoomOutBtn' style='border-top:1px solid #ccc;'>"); html.push(" <i class='fa fa-minus'></i>"); html.push(" </div>"); html.push(" </div>"); html.push("</div>"); var el = $compile(html.join(""))(scope); element.html(el); var chart = new VSBaiduMap({ width: element.width(), height: element.height(), mapDomId: mapDomId, dom: element[0] }); component.context.chart = chart; var option = component.config.chartConfig; option.onOverlayTooltipPanelClicked = function (overlayTooltip, overlayItem) { scope.onComponentClickEvent(scope.component, false, { click: overlayTooltip.eventConfig }) }; option.onOverlayItemClicked = function (overlayItem) { if (scope.component.config.linkageDimension == null) { alert("未配置联动维度"); return } var value = overlayItem[scope.component.config.linkageDimension.name]; if (component.config.pageFilter != null && component.config.pageFilter === true && (scope.component.config.rangeFilter == null || scope.component.config.rangeFilter === false)) { scope.cacheDimensionValue(scope.component.config.linkageDimension.name, value); $timeout(function () { scope.notifyDimensionValueFilterEvent({ queryConditionDimensions: true }) }) } else { scope.cacheDimensionValue(scope.component.config.linkageDimension.name, value); scope.notifyDimensionValueChange(null, scope.component.config.linkageDimension, value) } }; option.onMapCenterChanged = function () { if (component.config.rangeQuery != null && component.config.rangeQuery === true) { if (component.config.rangeQueryMeters == null) { component.config.rangeQueryMeters = 10000 } $timeout(function () { scope.$parent.queryConditionDimensions = true; scope.$broadcast(event_refreshBindingData, {}) }) } }; component.context.resize = function () { component.context.chart.resize(element.width(), element.height()) }; var refreshOverlay = function (scope, overlayItem, data) { var imageUrl = null; if (scope.component.config[overlayItem.overlayImageBind] != null) { imageUrl = scope.compileUrl(scope.component.config[overlayItem.overlayImageBind]) } var markerWidth = parseInt(scope.component.config[overlayItem.overlayImageWidthBind]); if (isNaN(markerWidth)) { markerWidth = 8 } var overlay = { name: scope.component.config[overlayItem.nameBind], type: scope.component.config[overlayItem.typeBind].value, marker: { image: imageUrl, width: markerWidth }, data: data }; var showColumns = scope.component.config["showColumns_" + overlayItem.name]; var tooltipShowColumns = []; if (showColumns != null) { for (var n = 0; n < showColumns.length; n++) { tooltipShowColumns.push({ name: showColumns[n].name, label: showColumns[n].label }) } } var tooltipBgColor = scope.component.config["bgColor_" + overlayItem.name]; if (!VSUtils.isValidColor(tooltipBgColor)) { tooltipBgColor = "#2990EA" } var tooltipFontColor = scope.component.config["fontColor_" + overlayItem.name]; if (!VSUtils.isValidColor(tooltipFontColor)) { tooltipFontColor = "#FFFFFF" } var borderColor = scope.component.config["borderColor_" + overlayItem.name]; if (!VSUtils.isValidColor(borderColor)) { borderColor = "#2990EA" } var textCenter = scope.component.config["textCenter_" + overlayItem.name]; if (!textCenter) { textCenter = "#2990EA" } var borderWidth = scope.component.config["borderWidth_" + overlayItem.name]; if (!borderWidth) { borderWidth = 1 } overlay.tooltip = { showColumns: tooltipShowColumns, eventConfig: {}, font: { color: tooltipFontColor, textCenter:textCenter, }, borderWidth:borderWidth, borderColor:borderColor, backgroundColor: tooltipBgColor, formatter: function () {} }; console.log(scope.component.config["position_" + overlayItem.name].value) var eventType = scope.component.config["eventType_" + overlayItem.name]; if (eventType != null) { overlay.tooltip.eventConfig.type = eventType.value; switch (eventType.value) { case "openPopupPanel": overlay.tooltip.eventConfig.reportPage = scope.component.config["reportPage_" + overlayItem.name]; overlay.tooltip.eventConfig.mask = { show: scope.component.config["hidePopupPanelBgMask_" + overlayItem.name] == null || scope.component.config["hidePopupPanelBgMask_" + overlayItem.name] === false }; overlay.tooltip.eventConfig.button = { show: scope.component.config["hideCloseButton_" + overlayItem.name] == null || scope.component.config["hideCloseButton_" + overlayItem.name] === false }; overlay.tooltip.eventConfig.position = { name: scope.component.config["position_" + overlayItem.name].value }; overlay.tooltip.eventConfig.positionFixed = scope.component.config["positionFixed" + overlayItem.name] == null || scope.component.config["positionFixed" + overlayItem.name] === false // overlay.tooltip.eventConfig.positionFixed = false; // overlay.tooltip.eventConfig.position = { // name:'centerPopup' // } break } } scope.component.context.chart.renderOverlay(overlay) }; var loadOverlayData = function (scope, overlayItem) { var dimensions = scope.component.config.datasourceConfig.dimensions; var measures = scope.component.config.datasourceConfig.measures; if (dimensions && dimensions.length > 0) { scope.component.config.chartDimensionCount = dimensions.length; scope.queryModelData({ eventParam: {}, dimensions: dimensions, measures: measures, overlayItem: overlayItem, targetDimension: scope.component.config[overlayItem.targetDimensionBind], includeDimensionValues: scope.component.config[overlayItem.includeDimensionValuesBind], sqlExpress: scope.component.config[overlayItem.sqlExpressBind], filterType: scope.component.config[overlayItem.filterTypeBind], tableKey: scope.component.config.datasourceConfig.metadataConfig.metadataTable.key, beforeQuery: function (param) { switch (param.filterType.value) { case "includeDimensionValues": if (param.targetDimension != null && !VSUtils.isEmpty(param.includeDimensionValues)) { param.inKeys.push(param.targetDimension.name); param.inValues.push(param.includeDimensionValues) } break; case "sqlExpress": if (!VSUtils.isEmpty(param.sqlExpress)) { param.filterKeys.push(" "); param.filterValues.push(param.sqlExpress) } break } }, onQuerySuccess: function (response, requestParam) { if (response.data.success) { refreshOverlay(scope, requestParam.overlayItem, response.data.data.data) if (scope.component.config.pageFilter != null && scope.component.config.pageFilter === true && scope.component.config.rangeFilter != null && scope.component.config.rangeFilter === true) { scope.notifyDimensionValueFilterEvent({ queryConditionDimensions: true }) } } else { toaster.error({ body: response.data.message }) } }, onError: function () { toaster.error({ body: vsLang.connection_failed }) } }) } }; var refreshChartView = function (scope, element, component, $compile) { var option = component.config.chartConfig; option.mapId = component.id; option.webKey = component.config.webKey; option.cacheLastLocation = component.config.cacheLastLocation; option.showToolbar = component.config.showToolbar; option.overlays = []; var overlayItems = scope.component.config.overlayItems; if (overlayItems != null) { setTimeout(function () { for (var m = 0; m < overlayItems.length; m++) { loadOverlayData(scope, overlayItems[m]) } }, 500) } scope.component.context.chart.setOption(option) }; scope.$on(event_refreshBindingData, function (target, param) { if (param != null && param.component != null && scope.component.id === param.component.id) { return } var dimensions = component.config.datasourceConfig.dimensions; if (dimensions && dimensions.length > 0) { refreshChartView(scope, element, component, $compile) } }); scope.$on(event_chartDimensionValueChange, function (s, event) { var dimensions = component.config.datasourceConfig.dimensions; if (dimensions == null || scope.component.config.linkageDimension == null) { return } if (dimensions != null && event.source.dimension.name === "" + scope.component.config.linkageDimension.name) { scope.component.context.chart.selectOverlayItemByColumnAndValue({ name: scope.component.config.linkageDimension.name, value: event.source.value }); if (scope.component.config.locationLinkage != null && scope.component.config.locationLinkage === true) { scope.component.context.chart.moveMapCenter({ name: scope.component.config.linkageDimension.name, value: event.source.value }) } } }); scope.component.context.beforeQuery = function (param) { var loc = component.context.chart.getMapCenter(); if (loc != null) { param.rangeCenter = loc.lat + "," + loc.lng } }; scope.component.context.getPageFilter = function () { var result = []; if (scope.component.context.chart != null && scope.component.config.linkageDimension != null) { if (scope.component.config.rangeFilter != null && scope.component.config.rangeFilter === true) { var data = scope.component.context.data; if (data != null && data.length > 0) { var values = []; for (var i = 0; i < data.length; i++) { values.push(data[i][scope.component.config.linkageDimension.name]) } result.push({ column: scope.component.config.linkageDimension.name, exp: "in", value: values.join(",") }) } else { result.push({ column: scope.component.config.linkageDimension.name, exp: "=", value: "" }) } } else { var selectedOverlayItem = scope.component.context.chart.getSelectedOverlayItem(); if (selectedOverlayItem != null) { var value = selectedOverlayItem[scope.component.config.linkageDimension.name]; result.push({ column: scope.component.config.linkageDimension.name, exp: "=", value: value }) } } } return result }; scope.component.context.shouldNotifyOnConditionDimensionValueChange = function () { if (component.config.pageFilter != null && component.config.pageFilter === true) { return false } return true }; scope.component.context.shouldRefreshOnConditionDimensionValueChange = function () { return false }; scope.component.context.onConditionDimensionValueChange = function () {} }; ``` 文件 WEB-INF\classes\report-resource\design-d3.js 搜索BaiduMapScriptLoader 方法 整个替换 ``` var BaiduMapScriptLoader = function (l) { var m = []; if (VSEngine.isWebDevice) { m.push({ url: contextPath + "/libs/pixi/pixi.min.js" }) } else { m.push({ url: serverPath + "/libs/pixi/pixi.min.js" }) } m.push({ url: "https://api.map.baidu.com/api?v=2.0&s=1&ak=" + l.webKey + "&callback=globalBaiduMapScriptLoader.onTagLoaded", wait: true }); var p = 0; var q = 0; var k = false; var o = function () { baiduMapJavascriptLoaded = true; l.onLoaded() }; var j = function (b, a) { var c = document.createElement("script"); c.setAttribute("src", b); if (a != null) { c.onload = a } document.head.appendChild(c) }; var n = function () { q++; if (q === m.length) { o(); return } if (p < m.length) { var a = m[p++]; j(a.url, a.wait ? null : n) } }; this.onTagLoaded = n; this.loadScript = function () { if (l.webKey == null) { console.log("请设置地图的WebKEY"); return } var a = m[p++]; j(a.url, a.wait ? null : n) } }; ``` 设计页直接 给你文件 也是直接替换