From b4586cdc2a23443a1bdafd2ec19fb3514e541905 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期六, 16 一月 2021 01:31:48 +0800
Subject: [PATCH] 增加mapbox插接件和功能

---
 src/views/mapbox/MapBoxHome.vue |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/src/views/mapbox/MapBoxHome.vue b/src/views/mapbox/MapBoxHome.vue
index 02dff1c..da47563 100644
--- a/src/views/mapbox/MapBoxHome.vue
+++ b/src/views/mapbox/MapBoxHome.vue
@@ -97,7 +97,7 @@
         tiles: [
           // 鑾峰彇GeoServer 鐭㈤噺鍒囩墖鏈嶅姟,鍙互鏄竴涓嬪嚑绉嶆柟寮�
           'http://localhost:8080/vector/tile/{z}/{x}/{y}' // postgis 鏁版嵁搴�
-          // "http://xearth.cn:6213/geoserver/gwc/service/tms/1.0.0/vectory_tile%3Acontrolpoint@EPSG%3A4326@pbf/{z}/{x}/{y}.pbf" //geoserver
+          // 'http://xearth.cn:6213/geoserver/gwc/service/tms/1.0.0/vectory_tile%3Acontrolpoint@EPSG%3A4326@pbf/{z}/{x}/{y}.pbf' // geoserver
         ]
       }
       var geojson = {
@@ -133,6 +133,7 @@
         style: {
           // 璁剧疆鐗堟湰鍙凤紝涓�瀹氳璁剧疆
           version: 8,
+          glyphs: 'http://http://xearth.cn:6213/sgis-assets/fonts/{fontstack}/{range}.pbf',
           // 娣诲姞鏉ユ簮
           sources: {
             tdtVec: tdtVec,
@@ -140,7 +141,8 @@
             wmts: wmts,
             buildings: buildings,
             // "wms":wms,
-            test: test
+            test: test,
+            anno: test
           },
           layers: [
             {
@@ -206,7 +208,7 @@
               type: 'circle',
               source: 'test',
               'source-layer': 'points',
-              // "source-layer": "controlpoint",
+              // 'source-layer': 'controlpoint',
               minzoom: 0,
               maxzoom: 18,
               // "paint": {
@@ -224,7 +226,7 @@
                   ]
                 },
                 'circle-color': {
-                  // property: 'v',
+                  // property: 'measattribute',
                   stops: [
                     [1, '#990055'],
                     [2, '#cdb640']
@@ -233,6 +235,51 @@
                 },
                 'circle-opacity': 1
               }
+            },
+            {
+              // 閮婂尯
+              id: 'anno',
+              type: 'symbol',
+              source: 'anno',
+              'source-layer': 'points',
+              minzoom: 14,
+              maxzoom: 17,
+              // filter: [
+              //   '==',
+              //   'fclass',
+              //   'suburb'
+              // ],
+              layout: {
+                'text-field': '{measattribute}',
+                // 'text-transform': 'uppercase',
+                'text-font': [
+                  // 杩欎釜灏辨槸{fontstack}锛屼篃灏辨槸瀛椾綋鏂囦欢澶圭殑鍚嶇О
+                  'Microsoft YaHei Regular'
+                ],
+                'text-letter-spacing': 0.15,
+                'text-max-width': 7,
+                'text-padding': 3,
+                'text-size': {
+                  base: 1,
+                  stops: [
+                    [
+                      11,
+                      11
+                    ],
+                    [
+                      15,
+                      18
+                    ]
+                  ]
+                }
+              },
+              paint: {
+                'text-halo-color': 'hsl(0, 0%, 100%)',
+                'text-halo-width': 1,
+                'text-color': 'hsl(230, 29%, 35%)',
+                'text-halo-blur': 0.5
+              },
+              interactive: true
             }
           ]
         },
@@ -253,8 +300,16 @@
       )
       // 娣诲姞瀵艰埅鎺т欢锛屾帶浠剁殑浣嶇疆鍖呮嫭'top-left', 'top-right','bottom-left' ,'bottom-right'鍥涚锛岄粯璁や负'top-right'
       map.addControl(nav, 'top-left')
-      map.on('click', function (e) {
+      // map.on('click', function (e) {
+      //   console.log(e)
+      // })
+      map.on('click', 'test', function (e) {
+        if (e.defaultPrevented) {
+          return
+        }
+        e.preventDefault()
         console.log(e)
+        console.log(e.features)
       })
       console.log(geojson)
     }

--
Gitblit v1.8.0