김성원 김성원 2023-09-06
맵레벨 처리
@0dc1f6acef2453f5a5516148c044d8d1413c728e
client/views/component/OpenLayers.vue
--- client/views/component/OpenLayers.vue
+++ client/views/component/OpenLayers.vue
@@ -23,6 +23,7 @@
 import proj4 from "proj4";
 import { register } from "ol/proj/proj4";
 import { Cluster } from 'ol/source';
+import { defaults } from 'ol/interaction';
 import { fromExtent } from 'ol/geom/Polygon';
 import OSM from 'ol/source/OSM.js';
 import Stamen from 'ol/source/Stamen.js';
@@ -109,12 +110,13 @@
     loadTilesWhileInteracting : true,
     view : new View({
         projection: this.baseSource,
-        resolutions: r,
+        resolutions:  r,
         zoom: 8,
         center : transform([339979.82131209393, 265331.9344441357], "EPSG:5181", vm.baseSource), //126.9757184, 37.564388 
+        constrainResolution: true
     }),
     target: "map",
-    constrainResolution: false,
+    interactions: defaults({ zoomDuration: 0 }),
     moveTolerance: 5
 	});
   this.mouse_ev();
client/views/component/OpenLayersNewMap.js
--- client/views/component/OpenLayersNewMap.js
+++ client/views/component/OpenLayersNewMap.js
@@ -33,12 +33,47 @@
     resolutions: r,
   });
 
+  var daumTileGrid = new ol.tilegrid.TileGrid({
+    extent : [(-30000-524288), (-60000-524288), (494288+524288), (988576+524288)],
+    tileSize : 256,
+    resolutions : [4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25], 
+    minZoom : 1
+  });
+
   var _utils = {
     selectDefaulyMapLayer: function (map) {
       let mapLayer = new TileLayer({
         source: new XYZ({  
-          url: 'https://api.vworld.kr/req/wmts/1.0.0/' + API_KEY + '/Base/{z}/{y}/{x}.png',
+          //url: 'https://api.vworld.kr/req/wmts/1.0.0/' + API_KEY + '/Base/{z}/{y}/{x}.png',
+          projection : 'EPSG:5179',
+          tileGrid: tileGrid,
+          // ilePixelRatio: 2,  
           tileSize: 256,
+          tileLoadFunction: function (imageTile, src) {
+            console.log(src)        
+            imageTile.getImage().src = src ;
+          },
+          tileUrlFunction: function (tileCoord, pixelRatio, projection) {
+            if (tileCoord == null) return undefined;                  
+         
+            var map_src = 'https://api.vworld.kr/req/wmts/1.0.0/' + API_KEY + '/Base/'
+            // let tileCoord = imageTile.getTileCoord();  
+            var bounds = tileGrid.getTileCoordExtent(tileCoord);
+            // console.log('bounds' , bounds)
+            //바로emap의 x,y,z 이미지파일이름을 구함
+            let res =  map.getView().getResolution();
+
+      //      console.log('res',res);
+            let f = res * 256;
+            let x = Math.round((bounds[0] - mapBounds[0]) / f);
+            let y = Math.round((bounds[1] - mapBounds[1]) / f);
+            let z = map.getView().getZoom() + 6;
+
+            z = (z < 10 ? "0" + z : z);
+            map_src = map_src + 'L' + z + '/' + x + '/' + y + '.png';
+        
+            return map_src
+          },
         }),          
         properties: { name: 'base-Layer' },      
         zIndex: 2,
Add a comment
List