底图省界部分修改

This commit is contained in:
wangxk 2025-07-23 11:06:57 +08:00
parent 10ef87753c
commit bc86834992
8 changed files with 72577 additions and 138058 deletions

View File

@ -38,7 +38,8 @@
"d3": "^7.9.0", "d3": "^7.9.0",
"default-passive-events": "^2.0.0", "default-passive-events": "^2.0.0",
"docx-preview": "^0.3.0", "docx-preview": "^0.3.0",
"echarts": "^5.2.2", "echarts": "^5.6.0",
"echarts-gl": "^2.0.9",
"element-plus": "^2.2.27", "element-plus": "^2.2.27",
"github-markdown-css": "^5.1.0", "github-markdown-css": "^5.1.0",
"highlight.js": "^10.7.2", "highlight.js": "^10.7.2",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,7 @@ import worldMap from './newJson.json'
const DEFAULT_MAP_SIZE = { width: 800, height: 600 } const DEFAULT_MAP_SIZE = { width: 800, height: 600 }
const PROJECTION_CENTER = [104, 37] // const PROJECTION_CENTER = [104, 37] //
const SCALE_FACTORS = { normal: 600, fullscreen: 1000 } const SCALE_FACTORS = { normal: 600, fullscreen: 1000 }
const isRouteInitialized = ref(false) // initqie
// ==================== Props/Emits ==================== // ==================== Props/Emits ====================
const props = defineProps({ const props = defineProps({
coordinates: { coordinates: {
@ -143,7 +143,13 @@ const renderChinaProvinces = (projection) => {
.append('path') .append('path')
.attr('class', 'province-path') .attr('class', 'province-path')
.attr('d', pathGenerator) .attr('d', pathGenerator)
.attr('fill', 'none') .attr('fill', d => {
//
if (d.properties.name === '四川省' || d.properties.name === "台湾省") {
return 'none'
}
return '#e7e7e7'
})
.attr('stroke', '#000') .attr('stroke', '#000')
.attr('stroke-width', 0.2) .attr('stroke-width', 0.2)
@ -155,7 +161,15 @@ const renderChinaProvinces = (projection) => {
.attr('class', 'province-label') .attr('class', 'province-label')
.attr('transform', d => { .attr('transform', d => {
const centroid = pathGenerator.centroid(d) const centroid = pathGenerator.centroid(d)
return `translate(${centroid[0]},${centroid[1]})` let [x, y] = centroid
//
if (d.properties.name === '河北省') {
x -= 3; y += 10;
} else if (d.properties.name === '甘肃省') {
x -= 3; y -= 10;
}
return `translate(${x},${y})`
}) })
.text(d => d.properties.name || '') .text(d => d.properties.name || '')
.attr('text-anchor', 'middle') .attr('text-anchor', 'middle')
@ -185,9 +199,12 @@ const updateRoute = () => {
const pathGenerator = d3.geoPath().projection(projection) const pathGenerator = d3.geoPath().projection(projection)
// 线 // 线
if (isRouteInitialized.value) {
routeGroup.selectAll('.route-path').remove() routeGroup.selectAll('.route-path').remove()
markersGroup.selectAll('*').remove() markersGroup.selectAll('*').remove()
isRouteInitialized.value = false
emit('qvehuan1', isRouteInitialized.value)
}
// 线 // 线
renderRoutePath(pathGenerator) renderRoutePath(pathGenerator)
renderMarkers(projection) renderMarkers(projection)
@ -199,7 +216,7 @@ const renderRoutePath = (path) => {
coordinates: props.coordinates coordinates: props.coordinates
} }
routeGroup.selectAll('.route-path').remove() // routeGroup.selectAll('.route-path').remove()
routeGroup.append('path') routeGroup.append('path')
.datum(routeData) .datum(routeData)
@ -274,7 +291,8 @@ onBeforeUnmount(() => {
// ==================== ==================== // ==================== ====================
watch(() => props.qvehuan, (newVal) => { watch(() => props.qvehuan, (newVal) => {
if (!newVal) updateRoute() isRouteInitialized.value = newVal
updateRoute()
}) })
watch(() => props.coordinates, () => { watch(() => props.coordinates, () => {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff