vue2-client 1.6.34 → 1.6.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +1,120 @@
1
- <template >
2
- <div id="amap_point_rendering_map" :style="mapStyle">
3
- <div v-show="false">
4
- <div id="amap_point_rendering_template">
5
- <a-descriptions :column="1">
6
- <a-descriptions-item v-for="(des, index) in describeList" :key="index" :label="des.describe" >{{ markers[des.field] }}</a-descriptions-item>
7
- </a-descriptions>
8
- </div>
9
- </div>
10
- </div>
11
- </template>
12
- <script>
13
- import { GetGDMap } from '@vue2-client/utils/map-utils'
14
- import { mapState } from 'vuex'
15
- export default {
16
- name: 'AmapPointRendering',
17
- props: {
18
- // 选中点位后需要展示的信息描述
19
- describeList: {
20
- type: Array,
21
- // eslint-disable-next-line vue/require-valid-default-prop
22
- default: () => { return [ ] } // lng:描述信息 lat:描述信息对应的值的字段名 { describe: '用户名称', field: 'name' }
23
- },
24
- // 需要渲染的点位数据
25
- markers: {
26
- type: String,
27
- default: null // lng:经度值 lat:纬度值
28
- },
29
- // 渲染点位的图片
30
- imgurl: {
31
- type: String,
32
- default: () => {
33
- return "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png"
34
- }
35
- },
36
- mapStyle: {
37
- type: Object,
38
- default: () => {
39
- return {
40
- width: '100%',
41
- height: '85vh',
42
- border: '2px solid lightgray',
43
- 'border-radius': '5px'
44
- }
45
- }
46
- }
47
- },
48
- computed: {
49
- ...mapState('setting', ['isMobile', 'gaode_key', 'gaode_secret_key'])
50
- },
51
- data () {
52
- return {
53
- map: null,
54
- geocoder: null, // 逆地理编码
55
- infoWindow: null,
56
- selectrow: {}
57
- }
58
- },
59
- created () {
60
- },
61
- mounted () {
62
- GetGDMap(this.gaode_secret_key, this.gaode_key).then(aMap => {
63
- this.initMap(aMap)
64
- this.initData(aMap)
65
- })
66
- },
67
- methods: {
68
- initMap (aMap) {
69
- this.map = new (aMap).Map('amap_point_rendering_map', { // 设置地图容器id
70
- resizeEnable: true, // 是否监控地图容器尺寸变化
71
- zoom: 10, // 初始化地图层级
72
- })
73
- this.geocoder = new (aMap).Geocoder({
74
- radius: 500 // 范围,默认:500
75
- })
76
- this.map.addControl(new (aMap).ToolBar()) // 初始化工具插件
77
- // 初始化窗体
78
- this.infoWindow = new (aMap).InfoWindow({
79
- anchor: 'bottom-center',
80
- isCustom: false, // 使用自定义窗体
81
- autoMove: true,
82
- content: '',
83
- showShadow: true,
84
- offset: new (aMap).Pixel(0, -25)
85
- })
86
- },
87
- initData (aMap) {
88
- // 创建一个 Marker 实例:
89
- if (this.markers) {
90
- const lngLat = this.markers.split(',')
91
- const lng = lngLat[0]
92
- const lat = lngLat[1]
93
- const marker = new (aMap).Marker({
94
- // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
95
- position: new (aMap).LngLat(lng, lat),
96
- icon: new (aMap).Icon({
97
- // 图标大小
98
- size: new (aMap).Size(26, 28),
99
- imageSize: new (aMap).Size(26, 28),
100
- // 报警图标URL
101
- image: this.imgurl,
102
- // 图标偏移位置
103
- anchor: new (aMap).Pixel(0, 0),
104
- }),
105
- extData: this.markers
106
- })
107
- marker.on('click', (e) => {
108
- if(e.target.getExtData() && e.target.getExtData().lng){
109
- this.infoWindow.setContent(document.getElementById('amap_point_rendering_template'))
110
- this.infoWindow.open(this.map, [e.target.getExtData().lng, e.target.getExtData().lat])
111
- }
112
- })
113
- // 将创建的点标记添加到已有的地图实例:
114
- this.map.add(marker)
115
- this.map.setFitView()
116
- }
117
- }
118
- }
119
- }
120
- </script>
1
+ <template >
2
+ <div id="amap_point_rendering_map" :style="mapStyle">
3
+ <div v-show="false">
4
+ <div id="amap_point_rendering_template">
5
+ <a-descriptions :column="1">
6
+ <a-descriptions-item v-for="(des, index) in describeList" :key="index" :label="des.describe" >{{ markers[des.field] }}</a-descriptions-item>
7
+ </a-descriptions>
8
+ </div>
9
+ </div>
10
+ </div>
11
+ </template>
12
+ <script>
13
+ import { GetGDMap } from '@vue2-client/utils/map-utils'
14
+ import { mapState } from 'vuex'
15
+ export default {
16
+ name: 'AmapPointRendering',
17
+ props: {
18
+ // 选中点位后需要展示的信息描述
19
+ describeList: {
20
+ type: Array,
21
+ // eslint-disable-next-line vue/require-valid-default-prop
22
+ default: () => { return [ ] } // lng:描述信息 lat:描述信息对应的值的字段名 { describe: '用户名称', field: 'name' }
23
+ },
24
+ // 需要渲染的点位数据
25
+ markers: {
26
+ type: String,
27
+ default: null // lng:经度值 lat:纬度值
28
+ },
29
+ // 渲染点位的图片
30
+ imgurl: {
31
+ type: String,
32
+ default: () => {
33
+ return "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png"
34
+ }
35
+ },
36
+ mapStyle: {
37
+ type: Object,
38
+ default: () => {
39
+ return {
40
+ width: '100%',
41
+ height: '85vh',
42
+ border: '2px solid lightgray',
43
+ 'border-radius': '5px'
44
+ }
45
+ }
46
+ }
47
+ },
48
+ computed: {
49
+ ...mapState('setting', ['isMobile', 'gaode_key', 'gaode_secret_key'])
50
+ },
51
+ data () {
52
+ return {
53
+ map: null,
54
+ geocoder: null, // 逆地理编码
55
+ infoWindow: null,
56
+ selectrow: {}
57
+ }
58
+ },
59
+ created () {
60
+ },
61
+ mounted () {
62
+ GetGDMap(this.gaode_secret_key, this.gaode_key).then(aMap => {
63
+ this.initMap(aMap)
64
+ this.initData(aMap)
65
+ })
66
+ },
67
+ methods: {
68
+ initMap (aMap) {
69
+ this.map = new (aMap).Map('amap_point_rendering_map', { // 设置地图容器id
70
+ resizeEnable: true, // 是否监控地图容器尺寸变化
71
+ zoom: 10, // 初始化地图层级
72
+ })
73
+ this.geocoder = new (aMap).Geocoder({
74
+ radius: 500 // 范围,默认:500
75
+ })
76
+ this.map.addControl(new (aMap).ToolBar()) // 初始化工具插件
77
+ // 初始化窗体
78
+ this.infoWindow = new (aMap).InfoWindow({
79
+ anchor: 'bottom-center',
80
+ isCustom: false, // 使用自定义窗体
81
+ autoMove: true,
82
+ content: '',
83
+ showShadow: true,
84
+ offset: new (aMap).Pixel(0, -25)
85
+ })
86
+ },
87
+ initData (aMap) {
88
+ // 创建一个 Marker 实例:
89
+ if (this.markers) {
90
+ const lngLat = this.markers.split(',')
91
+ const lng = lngLat[0]
92
+ const lat = lngLat[1]
93
+ const marker = new (aMap).Marker({
94
+ // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
95
+ position: new (aMap).LngLat(lng, lat),
96
+ icon: new (aMap).Icon({
97
+ // 图标大小
98
+ size: new (aMap).Size(26, 28),
99
+ imageSize: new (aMap).Size(26, 28),
100
+ // 报警图标URL
101
+ image: this.imgurl,
102
+ // 图标偏移位置
103
+ anchor: new (aMap).Pixel(0, 0),
104
+ }),
105
+ extData: this.markers
106
+ })
107
+ marker.on('click', (e) => {
108
+ if(e.target.getExtData() && e.target.getExtData().lng){
109
+ this.infoWindow.setContent(document.getElementById('amap_point_rendering_template'))
110
+ this.infoWindow.open(this.map, [e.target.getExtData().lng, e.target.getExtData().lat])
111
+ }
112
+ })
113
+ // 将创建的点标记添加到已有的地图实例:
114
+ this.map.add(marker)
115
+ this.map.setFitView()
116
+ }
117
+ }
118
+ }
119
+ }
120
+ </script>
@@ -1,3 +1,3 @@
1
- import AmapPointRendering from './AmapPointRendering'
2
-
3
- export default AmapPointRendering
1
+ import AmapPointRendering from './AmapPointRendering'
2
+
3
+ export default AmapPointRendering
@@ -1,24 +1,24 @@
1
- <template>
2
- <exception-page :home-route="homePage" :style="`min-height: ${minHeight}`" type="404" />
3
- </template>
4
-
5
- <script>
6
- import ExceptionPage from '@vue2-client/components/exception/ExceptionPage'
7
- import { mapState } from 'vuex'
8
- export default {
9
- name: 'Exp404',
10
- components: { ExceptionPage },
11
- computed: {
12
- homePage () {
13
- return '/'
14
- },
15
- ...mapState('setting', ['pageMinHeight']),
16
- minHeight () {
17
- return this.pageMinHeight ? this.pageMinHeight + 'px' : '100vh'
18
- }
19
- }
20
- }
21
- </script>
22
-
23
- <style scoped lang="less">
24
- </style>
1
+ <template>
2
+ <exception-page :home-route="homePage" :style="`min-height: ${minHeight}`" type="404" />
3
+ </template>
4
+
5
+ <script>
6
+ import ExceptionPage from '@vue2-client/components/exception/ExceptionPage'
7
+ import { mapState } from 'vuex'
8
+ export default {
9
+ name: 'Exp404',
10
+ components: { ExceptionPage },
11
+ computed: {
12
+ homePage () {
13
+ return '/'
14
+ },
15
+ ...mapState('setting', ['pageMinHeight']),
16
+ minHeight () {
17
+ return this.pageMinHeight ? this.pageMinHeight + 'px' : '100vh'
18
+ }
19
+ }
20
+ }
21
+ </script>
22
+
23
+ <style scoped lang="less">
24
+ </style>
@@ -1,37 +1,37 @@
1
- import AMapLoader from '@amap/amap-jsapi-loader'
2
- let Amap
3
- async function GetGDMap (secret_key,key) {
4
- if (!Amap) {
5
- window._AMapSecurityConfig = {
6
- securityJsCode: secret_key
7
- }
8
- Amap = await AMapLoader.load({
9
- key: key, // 申请好的Web端开发者Key,首次调用 load 时必填
10
- version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
11
- plugins: ['AMap.IndexCluster', 'AMP.MarkerCluster', 'AMap.InfoWindow', 'AMap.HeatMap', 'AMap.HawkEye', 'AMap.DistrictSearch',
12
- 'AMap.ToolBar', 'AMap.Geolocation',
13
- 'AMap.Geocoder', 'AMap.MarkerClusterer', 'AMap.AutoComplete'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
14
- AMapUI: {
15
- version: '1.1', // AMapUI 缺省 1.1
16
- plugins: [] // 需要加载的 AMapUI ui插件
17
- }
18
- })
19
- }
20
- return Amap
21
- }
22
- async function GetLocation (address) {
23
- return new Promise(async (resolve, reject) => {
24
- new (await GetGDMap()).Geocoder({
25
- radius: 500 // 范围,默认:500
26
- }).getLocation(address, function (status, result) {
27
- console.log(result)
28
- if (status === 'complete' && result.geocodes.length) {
29
- resolve({ lng: result.geocodes[0].location.lng, lat: result.geocodes[0].location.lat })
30
- } else {
31
- // eslint-disable-next-line prefer-promise-reject-errors
32
- reject('根据经纬度查询地址失败')
33
- }
34
- })
35
- })
36
- }
37
- export { GetGDMap, GetLocation }
1
+ import AMapLoader from '@amap/amap-jsapi-loader'
2
+ let Amap
3
+ async function GetGDMap (secret_key,key) {
4
+ if (!Amap) {
5
+ window._AMapSecurityConfig = {
6
+ securityJsCode: secret_key
7
+ }
8
+ Amap = await AMapLoader.load({
9
+ key: key, // 申请好的Web端开发者Key,首次调用 load 时必填
10
+ version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
11
+ plugins: ['AMap.IndexCluster', 'AMP.MarkerCluster', 'AMap.InfoWindow', 'AMap.HeatMap', 'AMap.HawkEye', 'AMap.DistrictSearch',
12
+ 'AMap.ToolBar', 'AMap.Geolocation',
13
+ 'AMap.Geocoder', 'AMap.MarkerClusterer', 'AMap.AutoComplete'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
14
+ AMapUI: {
15
+ version: '1.1', // AMapUI 缺省 1.1
16
+ plugins: ['misc/PositionPicker'] // 需要加载的 AMapUI ui插件
17
+ }
18
+ })
19
+ }
20
+ return Amap
21
+ }
22
+ async function GetLocation (address) {
23
+ return new Promise(async (resolve, reject) => {
24
+ new (await GetGDMap()).Geocoder({
25
+ radius: 500 // 范围,默认:500
26
+ }).getLocation(address, function (status, result) {
27
+ console.log(result)
28
+ if (status === 'complete' && result.geocodes.length) {
29
+ resolve({ lng: result.geocodes[0].location.lng, lat: result.geocodes[0].location.lat })
30
+ } else {
31
+ // eslint-disable-next-line prefer-promise-reject-errors
32
+ reject('根据经纬度查询地址失败')
33
+ }
34
+ })
35
+ })
36
+ }
37
+ export { GetGDMap, GetLocation }