@@ -13,123 +13,184 @@ import {
1313 LControlAttribution ,
1414 LControlLayers ,
1515 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';
2022
2123const mapOptions = {
2224 zoom: 13 ,
2325 center: { lat: 51.505 , lng: - 0.09 },
2426 minZoom: 8 ,
2527 maxZoom: 15 ,
2628 attributionControl: false ,
27- zoomControl: false
28- }
29+ zoomControl: false ,
30+ };
2931
3032const tileLayerOptions = {
31- attribution: ' vue-leaflet' ,
33+ attribution: " vue-leaflet" ,
3234 maxZoom: 18 ,
33- id: ' mapbox/streets-v11' ,
35+ id: " mapbox/streets-v11" ,
3436 tileSize: 512 ,
3537 zoomOffset: - 1 ,
36- accessToken: ' pk.eyJ1IjoieHdwaXNtZSIsImEiOiJ5cTlCQTlRIn0.QdV-wNUKbgs7jAlbVE747Q'
37- }
38+ accessToken:
39+ " pk.eyJ1IjoieHdwaXNtZSIsImEiOiJ5cTlCQTlRIn0.QdV-wNUKbgs7jAlbVE747Q" ,
40+ };
3841
3942const baseLayerOptions = {
4043 geoqBlue: new L .TileLayer (
4144 " http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}" ,
4245 {
43- attribution: " geoq blue"
46+ attribution: " geoq blue" ,
4447 }
4548 ),
46- ' 高德影像' : new L .TileLayer (
49+ 高德影像: new L .TileLayer (
4750 " http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}" ,
4851 {
4952 subdomains: " 1234" ,
50- attribution: " 高德影像"
53+ attribution: " 高德影像" ,
5154 }
52- )
53- }
55+ ),
56+ };
5457
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+ };
5571
5672 </script >
5773
5874<template >
5975 <div >
6076 <h1 >Basic UI Layers</h1 >
6177 <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+ >
6991 <l-tooltip :options =" { content: 'tooltip with marker1' }" />
7092 </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+ >
74100 <l-popup :options =" { content: 'popup with marker2' }" />
75101 </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+ />
78110 </l-map >
79111 </div >
80112 <div >
81113 <h1 >Vector Layers</h1 >
82114 <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+ />
111157 </l-map >
112158 </div >
113159 <div >
114160 <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+ />
122173 <LControlScale />
123174 <LControlZoom :options =" { position: 'topright' }" />
124175 <LControlAttribution />
125176 <LControlLayers :base-layers =" baseLayerOptions" />
126177 </l-map >
127178 </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 >
128192</template >
129193
130-
131-
132-
133194<style lang="css">
134195#app {
135196 width : 100% ;
@@ -138,7 +199,8 @@ const baseLayerOptions = {
138199
139200#map1 ,
140201#map2 ,
141- #map3 {
202+ #map3 ,
203+ #map4 {
142204 height : 300px ;
143205}
144206
@@ -152,4 +214,4 @@ body {
152214h1 {
153215 padding : 0 20px ;
154216}
155- </style >
217+ </style >
0 commit comments