Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
wxzgis committed Oct 9, 2020
1 parent 85e18dc commit 6d02461
Show file tree
Hide file tree
Showing 21 changed files with 241 additions and 145 deletions.
57 changes: 52 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"dependencies": {
"core-js": "^3.6.5",
"esri-loader": "^2.15.0",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
Expand All @@ -20,6 +20,8 @@
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"sass": "^1.27.0",
"sass-loader": "^10.0.2",
"typescript": "~3.9.3"
},
"browserslist": [
Expand Down
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="icon" href="<%= BASE_URL %>static/img/favicon.ico">
<link rel="stylesheet" href="<%= BASE_URL %>static/css/reset.css">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
Expand Down
9 changes: 9 additions & 0 deletions public/static/css/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
html body {
margin: 0;
padding: 0;
}

/* 去除地图黑边框 */
.esri-view .esri-view-surface--inset-outline:focus::after {
outline: unset !important;
}
File renamed without changes.
15 changes: 15 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineComponent } from 'vue'
import View from './components/View'
import '@/assets/style/app.scss'

export default defineComponent({
components: {
View
},
setup () {
return () =>
<div id="app">
<View class="view" />
</div>
}
})
30 changes: 0 additions & 30 deletions src/App.vue

This file was deleted.

Binary file removed src/assets/logo.png
Binary file not shown.
7 changes: 7 additions & 0 deletions src/assets/style/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#app {
height: 100vh;

.view {
height: inherit;
}
}
3 changes: 3 additions & 0 deletions src/assets/style/view.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.view {
height: 50vh;
}
64 changes: 0 additions & 64 deletions src/components/HelloWorld.vue

This file was deleted.

32 changes: 32 additions & 0 deletions src/components/View.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
defineComponent,
getCurrentInstance,
onMounted,
} from 'vue';
import { useStore } from 'vuex'
import { VIEW_DEFAULT_OPTIONS } from '@/config/esri.conf'
import { useEsri, useEsriUtils } from '@/hooks/esri';

export default defineComponent({
setup () {
const { ArcGISMap, MapView } = useEsri()
const store = useStore()

const { createBasemap } = useEsriUtils()

onMounted(() => {
const map = new ArcGISMap({
basemap: createBasemap('彩色中文含兴趣点版中国基础地图')
})

const view = new MapView({
map, ...VIEW_DEFAULT_OPTIONS
})

store.commit('setMapView', { map, view })
})

return () =>
<div id="view-container"></div>
}
})
34 changes: 34 additions & 0 deletions src/config/esri.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const ARCGIS_API_URL : string = 'https://wuxizhe.fun/arcgisjs/api/4.15'

export const ESRI_CONFIG = {
url: `${ARCGIS_API_URL}/init.js`,
css: `${ARCGIS_API_URL}/esri/themes/light/main.css`,
}

export const BASEMAPS = {
"彩色中文含兴趣点版中国基础地图": {
type: "WebTileLayer",
url: "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/{level}/{row}/{col}",
},
"灰色中文不含兴趣点版中国基础地图": {
type: "WebTileLayer",
url: "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer/tile/{level}/{row}/{col}",
},
"蓝黑色中文不含兴趣点版中国基础地图": {
type: "WebTileLayer",
url: "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{level}/{row}/{col}",
},
"暖色中文不含兴趣点版中国基础地图": {
type: "WebTileLayer",
url: "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer/tile/{level}/{row}/{col}",
}
}

export const VIEW_DEFAULT_OPTIONS = {
container: 'view-container',
zoom: 3,
center: [110, 10],
ui: {
components: []
}
}
25 changes: 25 additions & 0 deletions src/hooks/esri.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BASEMAPS } from '@/config/esri.conf';
import { reactive } from 'vue';

const esri = reactive({})

export function useEsriUtils () {

return {
set (obj : any) {
Object.assign(esri, { ...obj })
},
createBasemap (name: string) {
const { WebTileLayer } = useEsri()
const basemap = (BASEMAPS as any)[name]
if (basemap.type === 'WebTileLayer') {
return { baseLayers: [ new WebTileLayer({ urlTemplate: basemap.url }) ] }
}
},
}
}


export function useEsri () {
return ({ ...esri } as any)
}
28 changes: 26 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
import { createApp } from 'vue'
import App from './App.vue'
import App from './App'
import router from './router'
import store from './store'

createApp(App).use(store).use(router).mount('#app')
import { loadModules } from 'esri-loader'
import { ESRI_CONFIG } from './config/esri.conf'
import { useEsriUtils } from './hooks/esri'

const app = createApp(App)

loadModules([
'esri/Map',
'esri/views/MapView',
'esri/layers/WebTileLayer',
], ESRI_CONFIG).then(([
ArcGISMap,
MapView,
WebTileLayer,
]) => {
const { set } = useEsriUtils()
set({
ArcGISMap,
MapView,
WebTileLayer,
})

app.use(store).use(router).mount('#app')
})

Loading

0 comments on commit 6d02461

Please sign in to comment.