|
|
@@ -12,7 +12,8 @@
|
|
|
</div>
|
|
|
|
|
|
<div v-for="item in legendConfig" class="legend-item" @click="toggleRouteVisible(item.name)" :key="item.name"
|
|
|
- :class="{ 'is-inactive': !activeLegends.includes(item.name) }">
|
|
|
+ :class="{ 'is-inactive': !activeLegends.includes(item.name) }"
|
|
|
+ v-if="showSpecialRoutes || !['干线协调', '勤务路线'].includes(item.name)">
|
|
|
|
|
|
<div class="legend-dot"
|
|
|
:style="{ backgroundColor: ['离线', '降级', '故障'].includes(item.name) ? 'transparent' : item.color }"
|
|
|
@@ -41,7 +42,8 @@ export default {
|
|
|
name: "TrafficMap",
|
|
|
props: {
|
|
|
amapKey: { type: String, default: '您的Key' },
|
|
|
- securityJsCode: { type: String, default: '您的安全密钥' }
|
|
|
+ securityJsCode: { type: String, default: '您的安全密钥' },
|
|
|
+ showSpecialRoutes: { type: Boolean, default: true }
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -71,6 +73,18 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
+ // 根据props调整activeLegends数组
|
|
|
+ if (!this.showSpecialRoutes) {
|
|
|
+ const trunkCoordinationIndex = this.activeLegends.indexOf('干线协调');
|
|
|
+ if (trunkCoordinationIndex > -1) {
|
|
|
+ this.activeLegends.splice(trunkCoordinationIndex, 1);
|
|
|
+ }
|
|
|
+ const serviceRouteIndex = this.activeLegends.indexOf('勤务路线');
|
|
|
+ if (serviceRouteIndex > -1) {
|
|
|
+ this.activeLegends.splice(serviceRouteIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.initAMap();
|
|
|
|
|
|
// 自定义首页地图搜索和图例位置样式
|
|
|
@@ -138,6 +152,11 @@ export default {
|
|
|
const AMap = this.AMap;
|
|
|
|
|
|
this.legendConfig.forEach((config, index) => {
|
|
|
+ // 当showSpecialRoutes为false时,跳过干线协调和勤务路线
|
|
|
+ if (!this.showSpecialRoutes && ['干线协调', '勤务路线'].includes(config.name)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
setTimeout(() => {
|
|
|
const driving = new AMap.Driving({
|
|
|
map: null,
|