Naposledy aktivní 1740708970

네이버, 다음 지도 타일 요청 하는 경우. 오류가 발생하면 적용해야할 소스입니다.

bigdee revidoval tento gist 1740708970. Přejít na revizi

Žádné změny

bigdee revidoval tento gist 1740708924. Přejít na revizi

1 file changed, 113 insertions

name_daum_요청경로_수정.js(vytvořil soubor)

@@ -0,0 +1,113 @@
1 + // 설정값 링크: http://www.gisdeveloper.co.kr/?p=12587
2 + // 요청경로 참고: 네이버 + 카카오 맵, 대구 2d 지도 서비스
3 +
4 + // RsMapCore 네이버 설정
5 + this.__getLayerNaverMap = function (tileType){
6 + proj4.defs('EPSG:3857', '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs');
7 + ol.proj.setProj4 = proj4;
8 +
9 + var resolutions = [78000, 39000, 19600, 9800, 4900, 2400, 1222.9924523925781, 611.4962261962891, 305.74811309814453, 152.87405654907226, 76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508, 2.388657133579254, 1.194328566789627, 0.5971642833948135];
10 + var extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]; // 4 * 3
11 +
12 + var projection = new ol.proj.Projection({
13 + code: 'EPSG:3857',
14 + extent: extent,
15 + units: 'm'
16 + });
17 +
18 + var _id = this.ServiceType.BaseLayer.name + '-naver-' + tileType;
19 + var tileLayer = new ol.layer.Tile({
20 + id : _id,
21 + title : 'Naver ' + tileType + ' Map',
22 + visible : false,
23 + type : 'base',
24 + source : new ol.source.XYZ({
25 + projection: projection,
26 + crossOrigin : "anonymous",
27 + tileSize: 256,
28 + tilePixelRatio: 1.5, // 타일 이미지 화질 (1 ~ 2)
29 + minZoom: 0,
30 + maxZoom: resolutions.length - 1,
31 + tileGrid: new ol.tilegrid.TileGrid({
32 + extent: extent,
33 + origin: [extent[0], extent[2]], // y축 역배열 보정
34 + resolutions: resolutions
35 + }),
36 + tileUrlFunction: function (tileCoord, pixelRatio, projection) {
37 + if (tileCoord == null) return undefined;
38 +
39 + var z = tileCoord[0] + 1;
40 + var x = tileCoord[1];
41 + var y = tileCoord[2] + 1; // y축 보정값
42 +
43 +
44 + if (tileType === 'Base') {
45 + // 기본지도
46 + // * only http 요청만 -> return '//nrbe.map.naver.net/styles/basic/1717723233/' + z + '/' + x + '/' + -y + '@2x.png?mt=bg.ol.sw.ar.lko';
47 + return '//map.pstatic.net/nrb/styles/basic/1717723233/' + z + '/' + x + '/' + -y + '@2x.png?mt=bg.ol.sw.ar.lko'; // mt= 파라미터 삭제 시 피쳐 x
48 + } else {
49 + // 항공지도
50 + // * only http 요청만 -> return '//nrbe.map.naver.net/styles/satellite/1717723233/' + z + '/' + x + '/' + -y + '@2x.png?mt=bg.ol.sw.ar.lko';
51 + return '//map.pstatic.net/nrb/styles/satellite/1717723233/' + z + '/' + x + '/' + -y + '@2x.png?mt=bg.ol.sw.ar.lko'; // mt= 파라미터 삭제 시 피쳐 x
52 + }
53 + }
54 + })
55 + });
56 +
57 + return tileLayer;
58 + };
59 +
60 + // RsMapCore 카카오 설정
61 + this.__getLayerDaumMap = function (tileType){
62 + proj4.defs("EPSG:5181","+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
63 + ol.proj.setProj4 = proj4;
64 +
65 + var resolutions = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25];
66 + var extent = [-30000, -60000, 494288, 988576];
67 +
68 + var projection = new ol.proj.Projection({
69 + code: 'EPSG:5181',
70 + extent: extent,
71 + units: 'm'
72 + });
73 +
74 + var _id = this.ServiceType.BaseLayer.name + '-daum-' + tileType;
75 + var tileLayer = new ol.layer.Tile({
76 + id : _id,
77 + title : 'Daum Street Map',
78 + visible : false,
79 + type : 'base',
80 + source : new ol.source.XYZ({
81 + projection: projection,
82 + tileSize: 512,
83 + tilePixelRatio: 1.5, // 타일 이미지 화질 (1 ~ 2)
84 + minZoom: 0,
85 + maxZoom: resolutions.length - 1,
86 + tileGrid: new ol.tilegrid.TileGrid({
87 + origin: [extent[0], extent[1]],
88 + resolutions: resolutions
89 + }),
90 + tileUrlFunction: function (tileCoord, pixelRatio, projection) {
91 + if (tileCoord == null) return undefined;
92 +
93 + var s = Math.floor(Math.random() * 4); // 0 ~ 3
94 + var z = resolutions.length - tileCoord[0];
95 + var x = tileCoord[1];
96 + var y = tileCoord[2];
97 +
98 + // 카카오는 http, https 둘 다 가능
99 + // https가 적용된 웹페이지에서는 http 요청 자동으로 https로 업그레이드
100 + var _tileUrl = 'http://map.daumcdn.net/map_k3f_prod/bakery/image_map_png/PNG01/v29_9jh91/' + z + '/' + y + '/' + x + '.png';
101 + if (tileType === 'Satellite') {
102 + _tileUrl = 'http://map' + s + '.daumcdn.net/map_skyview_hd/L' + z + '/' + y + '/' + x + '.jpg?v=160107'; // 카카오는 피쳐레이어 별도로 제공
103 + } else if (tileType == 'Roadview') {
104 + _tileUrl = 'http://map.daumcdn.net/map_k3f_prod/bakery/image_map_png/PNG_RV01/v16_fs8a9/' + z + '/' + y + '/' + x + '.png';
105 + }
106 +
107 + return _tileUrl;
108 + }
109 + })
110 + });
111 +
112 + return tileLayer;
113 + };
Novější Starší