Skip to content

Commit 815464d

Browse files
add world map
1 parent 6d339a1 commit 815464d

File tree

12 files changed

+152
-3
lines changed

12 files changed

+152
-3
lines changed

public/world/jsvectormap.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/world/jsvectormap.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/world/world-merc.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/boot/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default boot(({ app }) => {
2424
app.use(vue3PhotoPreview);
2525
app.use(ElementPlus);
2626
app.config.globalProperties.$globalMessage = globalMessage;
27+
app.config.globalProperties.$window = window;
2728
app.config.globalProperties.$globalConfirm = globalConfirm;
2829
app.config.globalProperties.defaultFill = defaultFill;
2930
app.config.globalProperties.parseTime = (

src/env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ declare namespace NodeJS {
88
}
99
}
1010
// declare interface Window {
11-
// THREE: unknown;
11+
// jsVectorMap: unknown;
1212
// }

src/i18n/en-US/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default {
3434
colors: 'Colors',
3535
profile: 'Profile',
3636
parallax: 'Parallax',
37+
world: 'World',
3738
relationship: 'Relationship',
3839
map: 'China map',
3940
province: 'Province map',

src/i18n/zh-CN/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
dialog: '弹窗',
3434
profile: '个人中心',
3535
parallax: '视差',
36+
world: '世界地图标记',
3637
relationship: '关系图',
3738
map: '中国地图',
3839
province: '省份地图',

src/index.template.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@
3636
as="font"
3737
crossorigin
3838
/>
39+
<link
40+
rel="stylesheet"
41+
href="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>world/jsvectormap.min.css"
42+
/>
3943
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>less.min.js"></script>
4044
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>map/echarts.min.js"></script>
4145
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>map/china.js"></script>
4246
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>three/threejs.js"></script>
4347
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>three/orbit-controls.js"></script>
48+
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>world/jsvectormap.min.js"></script>
49+
<script src="<%= process.env.NODE_ENV !== 'production'?'/':'/v3-admin/'%>world/world-merc.js"></script>
4450
<style>
4551
.q-spinner-html {
4652
vertical-align: middle;

src/pages/charts/world.vue

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<template>
2+
<div>
3+
<div id="charts-world-map"></div>
4+
</div>
5+
</template>
6+
7+
<script lang="ts">
8+
import { getCurrentInstance } from 'vue';
9+
import { Component, Vue } from 'vue-facing-decorator';
10+
@Component({ name: 'myChartWorldComponent' })
11+
export default class myChartWorldComponent extends Vue {
12+
private globals = getCurrentInstance()!.appContext.config.globalProperties;
13+
mounted() {
14+
var markers = [
15+
{ name: 'Egypt', coords: [26.8206, 30.8025] },
16+
{ name: 'Russia', coords: [61.524, 105.3188] },
17+
{ name: 'Canada', coords: [56.1304, -106.3468] },
18+
{ name: 'Greenland', coords: [71.7069, -42.6043] },
19+
{ name: 'Brazil', coords: [-14.235, -51.9253] },
20+
];
21+
const map = new this.globals.$window.jsVectorMap({
22+
selector: '#charts-world-map',
23+
map: 'world_merc',
24+
zoomButtons: true,
25+
zoomOnScroll: true,
26+
regionStyle: {
27+
initial: {
28+
fill: '#d1d5db',
29+
},
30+
},
31+
labels: {
32+
markers: {
33+
render: (marker: any) => {
34+
return marker.name;
35+
},
36+
},
37+
},
38+
lines: [
39+
{
40+
from: 'Russia',
41+
to: 'Greenland',
42+
style: {
43+
stroke: '#000',
44+
},
45+
},
46+
],
47+
lineStyle: {
48+
stroke: '#676767',
49+
strokeWidth: 1.5,
50+
fill: '#ff5566',
51+
fillOpacity: 1,
52+
strokeDasharray: '6 3 6', // OR: [6, 2, 6]
53+
animation: true, // Enables animation
54+
},
55+
visualizeData: {
56+
scale: ['#eeeeee', '#999999'],
57+
values: {
58+
EG: 29,
59+
US: 100,
60+
CA: 190,
61+
BR: 75,
62+
// ...
63+
},
64+
},
65+
// focusOn: { 聚焦某国家
66+
// regions: ['EG', 'SA'],
67+
// animate: true,
68+
// },
69+
series: {
70+
regions: [
71+
{
72+
attribute: 'fill',
73+
legend: {
74+
title: 'Some title',
75+
},
76+
scale: {
77+
myScaleOne: '#c79efd',
78+
myScaleTwo: '#ffc371',
79+
myScaleThree: '#08d191',
80+
},
81+
values: {
82+
// But when dealing with regions's series you should specify the region key.
83+
CN: 'myScaleTwo',
84+
MX: 'myScaleOne',
85+
LY: 'myScaleOne',
86+
RU: 'myScaleThree',
87+
},
88+
},
89+
],
90+
},
91+
regionsSelectable: false,
92+
markersSelectable: true,
93+
selectedMarkers: markers.map((marker, index) => {
94+
var name = marker.name;
95+
if (name === 'Russia' || name === 'Brazil') {
96+
return index;
97+
}
98+
}),
99+
markers: markers,
100+
markerStyle: {
101+
initial: { fill: '#5c5cff' },
102+
selected: { fill: '#ff5050' },
103+
},
104+
markerLabelStyle: {
105+
initial: {
106+
fontFamily: 'NotoSans-Regular, NotoSansSC-Regular',
107+
fontWeight: 400,
108+
fontSize: 13,
109+
},
110+
},
111+
});
112+
}
113+
}
114+
</script>
115+
116+
117+
<style lang="scss" scoped>
118+
#charts-world-map {
119+
margin: auto;
120+
width: 100%;
121+
height: 800px;
122+
text-align: center;
123+
}
124+
</style>

src/router/routes.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,25 @@ export const asyncRoutes: RouteRecordRaw[] = [
9898
icon: 'bar_chart',
9999
pagePermissionId: [
100100
'charts',
101+
'charts-world',
101102
'charts-relationship',
102103
'charts-map',
103104
'charts-province',
104105
'charts-city',
105106
],
106107
},
107108
children: [
109+
{
110+
path: 'world',
111+
name: 'World',
112+
meta: {
113+
title: 'world',
114+
icon: 'label',
115+
pagePermissionId: ['charts-world'],
116+
},
117+
component: () =>
118+
import(/* webpackChunkName: "world" */ 'src/pages/charts/world.vue'),
119+
},
108120
{
109121
path: 'relationship',
110122
name: 'Relationship',
@@ -115,7 +127,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
115127
},
116128
component: () =>
117129
import(
118-
/* webpackChunkName: "line" */ 'src/pages/charts/relationship.vue'
130+
/* webpackChunkName: "relationship" */ 'src/pages/charts/relationship.vue'
119131
),
120132
},
121133
{

0 commit comments

Comments
 (0)