@@ -13,123 +13,184 @@ import {
13
13
LControlAttribution ,
14
14
LControlLayers ,
15
15
LControlZoom ,
16
- LControlScale
17
- } from ' ../src' ;
18
- import ' ../node_modules/leaflet/dist/leaflet.css' ;
19
- import L from ' leaflet' ;
16
+ LControlScale ,
17
+ LGeojson ,
18
+ } from " ../src" ;
19
+ import " ../node_modules/leaflet/dist/leaflet.css" ;
20
+ import L from " leaflet" ;
21
+ // import { type GeoJsonObject } from 'geojson';
20
22
21
23
const mapOptions = {
22
24
zoom: 13 ,
23
25
center: { lat: 51.505 , lng: - 0.09 },
24
26
minZoom: 8 ,
25
27
maxZoom: 15 ,
26
28
attributionControl: false ,
27
- zoomControl: false
28
- }
29
+ zoomControl: false ,
30
+ };
29
31
30
32
const tileLayerOptions = {
31
- attribution: ' vue-leaflet' ,
33
+ attribution: " vue-leaflet" ,
32
34
maxZoom: 18 ,
33
- id: ' mapbox/streets-v11' ,
35
+ id: " mapbox/streets-v11" ,
34
36
tileSize: 512 ,
35
37
zoomOffset: - 1 ,
36
- accessToken: ' pk.eyJ1IjoieHdwaXNtZSIsImEiOiJ5cTlCQTlRIn0.QdV-wNUKbgs7jAlbVE747Q'
37
- }
38
+ accessToken:
39
+ " pk.eyJ1IjoieHdwaXNtZSIsImEiOiJ5cTlCQTlRIn0.QdV-wNUKbgs7jAlbVE747Q" ,
40
+ };
38
41
39
42
const baseLayerOptions = {
40
43
geoqBlue: new L .TileLayer (
41
44
" http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}" ,
42
45
{
43
- attribution: " geoq blue"
46
+ attribution: " geoq blue" ,
44
47
}
45
48
),
46
- ' 高德影像' : new L .TileLayer (
49
+ 高德影像: new L .TileLayer (
47
50
" http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}" ,
48
51
{
49
52
subdomains: " 1234" ,
50
- attribution: " 高德影像"
53
+ attribution: " 高德影像" ,
51
54
}
52
- )
53
- }
55
+ ),
56
+ };
54
57
58
+ const tmpGeojson = {
59
+ " type" : " Feature" ,
60
+ " geometry" : {
61
+ " type" : " Polygon" ,
62
+ " coordinates" : [
63
+ [
64
+ [- 0.08 , 51.509 ],
65
+ [- 0.06 , 51.503 ],
66
+ [- 0.047 , 51.51 ],
67
+ ]
68
+ ]
69
+ }
70
+ };
55
71
56
72
</script >
57
73
58
74
<template >
59
75
<div >
60
76
<h1 >Basic UI Layers</h1 >
61
77
<l-map id =" map1" :options =" mapOptions" >
62
- <l-tilelayer urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
63
- :options =" tileLayerOptions" />
64
- <l-marker id =" marker1" :latlng =" { lat: 51.505, lng: -0.09 }" :options =" {
65
- title: 'marker1',
66
- opacity: 1,
67
- draggable: true
68
- }" >
78
+ <l-tilelayer
79
+ urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
80
+ :options =" tileLayerOptions"
81
+ />
82
+ <l-marker
83
+ id =" marker1"
84
+ :latlng =" { lat: 51.505, lng: -0.09 }"
85
+ :options =" {
86
+ title: 'marker1',
87
+ opacity: 1,
88
+ draggable: true,
89
+ }"
90
+ >
69
91
<l-tooltip :options =" { content: 'tooltip with marker1' }" />
70
92
</l-marker >
71
- <l-marker id =" marker2" :latlng =" { lat: 51.505, lng: -0.11 }" :options =" {
72
- title: 'marker2'
73
- }" >
93
+ <l-marker
94
+ id =" marker2"
95
+ :latlng =" { lat: 51.505, lng: -0.11 }"
96
+ :options =" {
97
+ title: 'marker2',
98
+ }"
99
+ >
74
100
<l-popup :options =" { content: 'popup with marker2' }" />
75
101
</l-marker >
76
- <l-tooltip :options =" { content: 'tooltip standalone' }" :latlng =" { lat: 51.505, lng: 0 }" />
77
- <l-popup :options =" { content: 'popup standalone' }" :latlng =" { lat: 51.505, lng: 0 }" />
102
+ <l-tooltip
103
+ :options =" { content: 'tooltip standalone' }"
104
+ :latlng =" { lat: 51.505, lng: 0 }"
105
+ />
106
+ <l-popup
107
+ :options =" { content: 'popup standalone' }"
108
+ :latlng =" { lat: 51.505, lng: 0 }"
109
+ />
78
110
</l-map >
79
111
</div >
80
112
<div >
81
113
<h1 >Vector Layers</h1 >
82
114
<l-map id =" map2" :options =" mapOptions" >
83
- <l-tilelayer urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
84
- :options =" tileLayerOptions" />
85
- <l-circle :latlng =" [51.508, -0.11]" :options =" {
86
- color: 'red',
87
- fillColor: '#f03',
88
- fillOpacity: 0.5,
89
- radius: 500
90
- }" />
91
- <LCircleMarker :latlng =" [51.512, -0.18]" :options =" {
92
- color: 'red',
93
- fillColor: '#f03',
94
- fillOpacity: 0.5,
95
- radius: 100
96
- }" />
97
- <l-polygon :latlngs =" [
98
- [51.509, -0.08],
99
- [51.503, -0.06],
100
- [51.51, -0.047]
101
- ]" />
102
- <l-polyline :latlngs =" [
103
- [51.510, -0.09],
104
- [51.505, -0.07],
105
- [51.56, -0.048]
106
- ]" />
107
- <l-rectangle :latLngBounds =" [
108
- [51.510, -0.09],
109
- [51.505, -0.07],
110
- ]" />
115
+ <l-tilelayer
116
+ urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
117
+ :options =" tileLayerOptions"
118
+ />
119
+ <l-circle
120
+ :latlng =" [51.508, -0.11]"
121
+ :options =" {
122
+ color: 'red',
123
+ fillColor: '#f03',
124
+ fillOpacity: 0.5,
125
+ radius: 500,
126
+ }"
127
+ />
128
+ <LCircleMarker
129
+ :latlng =" [51.512, -0.18]"
130
+ :options =" {
131
+ color: 'red',
132
+ fillColor: '#f03',
133
+ fillOpacity: 0.5,
134
+ radius: 100,
135
+ }"
136
+ />
137
+ <l-polygon
138
+ :latlngs =" [
139
+ [51.509, -0.08],
140
+ [51.503, -0.06],
141
+ [51.51, -0.047],
142
+ ]"
143
+ />
144
+ <l-polyline
145
+ :latlngs =" [
146
+ [51.51, -0.09],
147
+ [51.505, -0.07],
148
+ [51.56, -0.048],
149
+ ]"
150
+ />
151
+ <l-rectangle
152
+ :latLngBounds =" [
153
+ [51.51, -0.09],
154
+ [51.505, -0.07],
155
+ ]"
156
+ />
111
157
</l-map >
112
158
</div >
113
159
<div >
114
160
<h1 >Control</h1 >
115
- <l-map id =" map3" :options =" {
116
- ...mapOptions,
117
- zoom: 10,
118
- center: { lat: 26.33280692289788, lng: 114.78515624999999 },
119
- }" >
120
- <l-tilelayer urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
121
- :options =" tileLayerOptions" />
161
+ <l-map
162
+ id =" map3"
163
+ :options =" {
164
+ ...mapOptions,
165
+ zoom: 10,
166
+ center: { lat: 26.33280692289788, lng: 114.78515624999999 },
167
+ }"
168
+ >
169
+ <l-tilelayer
170
+ urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
171
+ :options =" tileLayerOptions"
172
+ />
122
173
<LControlScale />
123
174
<LControlZoom :options =" { position: 'topright' }" />
124
175
<LControlAttribution />
125
176
<LControlLayers :base-layers =" baseLayerOptions" />
126
177
</l-map >
127
178
</div >
179
+ <div >
180
+ <h1 >Feature Layer</h1 >
181
+ <l-map
182
+ id =" map4"
183
+ :options =" mapOptions"
184
+ >
185
+ <l-tilelayer
186
+ urlTemplate =" https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
187
+ :options =" tileLayerOptions"
188
+ />
189
+ <LGeojson :geojson =" tmpGeojson" />
190
+ </l-map >
191
+ </div >
128
192
</template >
129
193
130
-
131
-
132
-
133
194
<style lang="css">
134
195
#app {
135
196
width : 100% ;
@@ -138,7 +199,8 @@ const baseLayerOptions = {
138
199
139
200
#map1 ,
140
201
#map2 ,
141
- #map3 {
202
+ #map3 ,
203
+ #map4 {
142
204
height : 300px ;
143
205
}
144
206
@@ -152,4 +214,4 @@ body {
152
214
h1 {
153
215
padding : 0 20px ;
154
216
}
155
- </style >
217
+ </style >
0 commit comments