|
8 | 8 | h2 {
|
9 | 9 | font-size: 1rem;
|
10 | 10 | }
|
11 |
| - html { |
| 11 | + html,body,.main { |
12 | 12 | height: 100%;
|
13 | 13 | }
|
14 |
| - body { |
15 |
| - height: 100%; |
16 |
| - padding: 0; |
| 14 | + body{ |
17 | 15 | margin: 0;
|
18 |
| - font-family: '微软雅黑'; |
19 |
| - font-size: 14px; |
| 16 | + padding: 0; |
20 | 17 | }
|
21 | 18 |
|
22 |
| - table { |
23 |
| - border-collapse: collapse; |
24 |
| - border-spacing: 0; |
25 |
| - empty-cells: show; |
26 |
| - border: 1px solid #cbcbcb; |
27 |
| - |
| 19 | + .gps-container{ |
| 20 | + height: 100%; |
| 21 | + display: flex; |
| 22 | + flex-flow: column nowrap; |
28 | 23 | }
|
29 |
| - td, |
30 |
| - th { |
31 |
| - border-left: 1px solid #cbcbcb; |
32 |
| - border-width: 0 0 0 1px; |
33 |
| - font-size: inherit; |
34 |
| - margin: 0; |
35 |
| - overflow: visible; |
36 |
| - padding: 0.5em 1em; |
37 |
| - border-bottom: 1px solid #cbcbcb; |
| 24 | + |
| 25 | + .container{ |
| 26 | + flex: 1; |
38 | 27 | }
|
39 |
| - .container { |
40 |
| - height: 500px; |
| 28 | + |
| 29 | + .fullscreen{ |
| 30 | + position: absolute; |
| 31 | + z-index: 1; |
| 32 | + color: #e6e6e6; |
| 33 | + font-weight: 400; |
| 34 | + cursor: pointer; |
41 | 35 | }
|
| 36 | + |
42 | 37 | .picker {
|
43 | 38 | display: none;
|
44 | 39 | }
|
| 40 | + |
| 41 | + footer{ |
| 42 | + display: flex; |
| 43 | + } |
| 44 | + |
| 45 | + .otherMsg{ |
| 46 | + padding-left: 10px; |
| 47 | + } |
| 48 | + |
| 49 | + .img-marker{ |
| 50 | + display: block; |
| 51 | + width: 200px; |
| 52 | + height: 100px; |
| 53 | + background-size: contain; |
| 54 | + background-repeat: no-repeat; |
| 55 | + background-position: center; |
| 56 | + } |
| 57 | + |
| 58 | + h5{ |
| 59 | + margin-top: 0; |
| 60 | + } |
45 | 61 | @media screen and (max-width: 500px) {
|
46 | 62 | body,
|
47 | 63 | html {
|
48 | 64 | font-size: 28px;
|
49 |
| - |
50 | 65 | }
|
51 | 66 | h2 {
|
52 | 67 | display: none;
|
|
58 | 73 | </style>
|
59 | 74 | <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=05fb23d2c6d3ce6323793cd981030e9f&plugin=AMap.Geocoder"></script>
|
60 | 75 | <script src="/resource/2018/exif.js"></script>
|
61 |
| -<script src="/resource/2019/map_convertor.js"></script> |
62 | 76 | <script src="/resource/2021/gpsConvert.js"></script>
|
63 |
| -<h2>把图片拖进来</h2> |
64 |
| -<div class="picker"><input type="file" id="filePicker"></div> |
65 |
| -<div id="makeAndModel" style="height: 30px; "></div> |
66 |
| -<div class="map_shift" id="mapShift"> |
67 |
| - |
68 |
| - <label for="satellite">卫星图</label><input type="checkbox" id="satellite"/> |
69 | 77 |
|
| 78 | +<div class="gps-container"> |
| 79 | + <h2>把图片拖进来</h2> |
| 80 | + <div class="container" id="mapCtn"> |
| 81 | + <div class="fullscreen">全屏</div> |
| 82 | + </div> |
| 83 | + <div id="makeAndModel" style="height: 30px; "></div> |
| 84 | + <footer> |
| 85 | + <div class="detail" id="picDetail"></div> |
| 86 | + <div class="otherMsg"></div> |
| 87 | + </footer> |
70 | 88 | </div>
|
71 |
| -<div class="container" id="mapCtn"></div> |
72 |
| -<div class="detail" id="picDetail"></div> |
73 | 89 |
|
74 |
| -<script> |
75 |
| - function $(selector) { |
76 |
| - return document.querySelector(selector); |
77 |
| - } |
78 |
| - |
79 |
| - var pageControl = { |
80 |
| - init: function () { |
81 |
| - const mapContainer = $('#mapCtn'); |
82 |
| - const googleLayer = new AMap.TileLayer({tileUrl: 'http://mt2.google.cn/vt/lyrs=y&hl=zh-CN&gl=cn&x=[x]&y=[y]&z=[z]&s=Galil', zIndex: 3}); |
83 |
| - const map = new AMap.Map(mapContainer, { |
84 |
| - resizeEnable: true, |
85 |
| - zoom: 15, |
86 |
| - center: [ |
87 |
| - 116.397428, 39.90923 |
88 |
| - ], |
89 |
| - layers: [googleLayer] |
90 |
| - }); |
91 |
| - var marker = new AMap.Marker({ |
92 |
| - position: new AMap.LngLat(116.397428, 39.90923), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9] |
93 |
| - title: '北京' |
94 |
| - }); |
95 |
| - |
96 |
| - // 将创建的点标记添加到已有的地图实例: |
97 |
| - map.add(marker); |
98 |
| - |
99 |
| - this.map = map; |
100 |
| - const _this = this; |
101 |
| - //拖动 |
102 |
| - var dragW = document.body; |
103 |
| - dragW.addEventListener("dragenter", function (e) { |
104 |
| - e.preventDefault(); |
105 |
| - }); |
106 |
| - dragW.addEventListener("dragover", function (e) { |
107 |
| - //console.log('dragover:', e); |
108 |
| - e.preventDefault(); |
109 |
| - }); |
110 |
| - dragW.addEventListener("dragleave", function (e) { |
111 |
| - //console.log('dragleave:', e); |
112 |
| - e.preventDefault(); |
113 |
| - }); |
114 |
| - dragW.addEventListener("drop", function (e) { |
115 |
| - e.preventDefault(); |
116 |
| - _this.getFiles(e.dataTransfer.files); |
117 |
| - }); |
118 |
| - var filePicker = document.getElementById("filePicker"); |
119 |
| - filePicker.addEventListener("change", function (e) { |
120 |
| - console.log(this); |
121 |
| - _this.getFiles(this.files); |
122 |
| - }); |
123 |
| - //图片 |
124 |
| - this.picDetail = document.getElementById("picDetail"); |
125 |
| - |
126 |
| - //this.changeMapTo('baidu'); |
127 |
| - }, |
128 |
| - addMarker: function (x, y) { |
129 |
| - var bdGps = coordtransform.wgs84togcj02(x, y); |
130 |
| - var bdPoint = new AMap.LngLat(bdGps[0], bdGps[1]); |
131 |
| - var bdMarker = new AMap.Marker(bdPoint); // 创建点 |
132 |
| - Promise |
133 |
| - .resolve() |
134 |
| - .then(() => { |
135 |
| - this |
136 |
| - .map |
137 |
| - .add(bdMarker); |
138 |
| - }) |
139 |
| - |
140 |
| - return bdPoint; |
141 |
| - }, |
142 |
| - baiduMap: { |
143 |
| - init: function (ctn) { |
144 |
| - // 参考文章:https://its304.com/article/wclwksn2019/106992429 |
145 |
| - var googleLayer = new AMapGL.TileLayer(); |
146 |
| - googleLayer.getTilesUrl = function (tileCoord, zoom) { |
147 |
| - var tileX = tileCoord.x; |
148 |
| - var tileY = tileCoord.y; |
149 |
| - var pixelX = 10; |
150 |
| - var pixelY = 10; |
151 |
| - var level = zoom; |
152 |
| - const coord = TileLnglatTransformBaidu.pixelToLnglat(pixelX, pixelY, tileX, tileY, level); |
153 |
| - console.log('coord: ', coord); |
154 |
| - |
155 |
| - const longitude = coord.lng; |
156 |
| - const latitude = coord.lat; |
157 |
| - |
158 |
| - const googleTile = TileLnglatTransformGoogle.lnglatToTile(longitude, latitude, level); |
159 |
| - |
160 |
| - var url = `http://mt2.google.cn/vt/lyrs=s&hl=zh-CN&gl=cn&x=${googleTile.tileX}&y=${googleTile.tileY}&z=${zoom}&s=Galil`; |
161 |
| - return url; |
162 |
| - } |
163 |
| - googleLayer.zIndex = 0; |
164 |
| - |
165 |
| - var map = new AMapGL.Map(ctn); |
166 |
| - |
167 |
| - var isTilesPng = true; |
168 |
| - var tileSize = 256; |
169 |
| - var tstyle = 'pl'; |
170 |
| - var udtVersion = '20190102'; |
171 |
| - var tilelayer = new AMapGL.TileLayer({transparentPng: isTilesPng}); |
172 |
| - tilelayer.zIndex = 110; |
173 |
| - // point为图块坐标,level为图块的级别 |
174 |
| - // 当地图需要显示特定级别的特定位置的图块时会自动调用此方法,并提供这两个参数 |
175 |
| - tilelayer.getTilesUrl = function (tileCoord, zoom) { |
176 |
| - var tileX = tileCoord.x; |
177 |
| - var tileY = tileCoord.y; |
178 |
| - var pixelX = 128; |
179 |
| - var pixelY = 128; |
180 |
| - var level = zoom; |
181 |
| - const coord = TileLnglatTransformBaidu.pixelToLnglat(pixelX, pixelY, tileX, tileY, level); |
182 |
| - console.log('coord: ', coord, zoom); |
183 |
| - |
184 |
| - const gc02 = coordtransform.bd09togcj02(coord.lng, coord.lat); |
185 |
| - const wgs84 = coordtransform.gcj02towgs84(gc02[0], gc02[1]); |
186 |
| - |
187 |
| - const longitude = gc02[0]; |
188 |
| - const latitude = gc02[1]; |
189 |
| - |
190 |
| - const googleTile = TileLnglatTransformGoogle.lnglatToTile(longitude, latitude, level); |
191 |
| - |
192 |
| - var url = `http://mt2.google.cn/vt/lyrs=s&hl=zh-CN&gl=cn&x=${googleTile.tileX}&y=${googleTile.tileY}&z=${zoom}&s=Galil`; |
193 |
| - //var url = `https://khms0.google.com/kh/v=908?x=${googleTile.tileX}&y=${googleTile.tileY}&z=${zoom}`; |
194 |
| - return url; |
195 |
| - }; |
196 |
| - map.addTileLayer(tilelayer); |
197 |
| - |
198 |
| - console.log('googleLayer: ', googleLayer); |
199 |
| - |
200 |
| - // 创建地图实例 |
201 |
| - var point = new AMapGL.LngLat(116.404, 39.915); |
202 |
| - // 创建点坐标 |
203 |
| - map.setZoomAndCenter(15, point); |
204 |
| - // 初始化地图,设置中心点坐标和地图级别 |
205 |
| - var marker = new AMapGL.Marker(point); // 创建点 |
206 |
| - map.enableScrollWheelZoom(true); |
207 |
| - map.add(marker); |
208 |
| - this.marker = marker; |
209 |
| - this.map = map; |
210 |
| - }, |
211 |
| - addMarker: function (x, y) { |
212 |
| - var bdGps = GPS.GPSToBaidu(y, x); |
213 |
| - var bdPoint = new AMap.LngLat(bdGps.lng, bdGps.lat); |
214 |
| - var bdMarker = new AMap.Marker(bdPoint); // 创建点 |
215 |
| - this |
216 |
| - .map |
217 |
| - .add(bdMarker); |
218 |
| - return bdPoint; |
219 |
| - } |
220 |
| - }, |
221 |
| - getFiles: function (fileList) { |
222 |
| - var _this = this; |
223 |
| - var imgCtn = document.getElementById('imgCtn'); |
224 |
| - const zoomPoints = []; |
225 |
| - for (let i = 0; i < fileList.length; i++) { |
226 |
| - var file = fileList[i]; |
227 |
| - if (file.type.indexOf('image') === -1) { |
228 |
| - console.log('此文件不是图片:', file.name); |
229 |
| - continue; |
230 |
| - } |
231 |
| - if (window.URL.createObjectURL) { //使用完成后可以通过revokeObjectURL释放内存 |
232 |
| - var tempImg = document.createElement('img'); |
233 |
| - tempImg.src = window |
234 |
| - .URL |
235 |
| - .createObjectURL(file); |
236 |
| - console.log('通过URL创建图片', file); |
237 |
| - //imgCtn.appendChild(tempImg); |
238 |
| - EXIF.getData(file, function () { |
239 |
| - var lon = EXIF.getTag(this, "GPSLongitude"); |
240 |
| - var lat = EXIF.getTag(this, "GPSLatitude"); |
241 |
| - var GPSLongitudeRef = EXIF.getTag(this, "GPSLongitudeRef"); |
242 |
| - var GPSLatitudeRef = EXIF.getTag(this, "GPSLatitudeRef"); |
243 |
| - makeAndModel.innerHTML = `${lon} ${GPSLongitudeRef} ${lat} ${GPSLatitudeRef}`; |
244 |
| - const {x, y} = _this.renderPoint(lon, lat, GPSLongitudeRef, GPSLatitudeRef); |
245 |
| - console.log(x, y) |
246 |
| - const bdPoints = _this.addMarker(x, y); |
247 |
| - console.log(i) |
248 |
| - zoomPoints.push(bdPoints); |
249 |
| - if (zoomPoints.length === 1) { |
250 |
| - _this |
251 |
| - .map |
252 |
| - .setZoomAndCenter(15, bdPoints); |
253 |
| - } |
254 |
| - _this.renderPictureDetail(this); |
255 |
| - }); |
256 |
| - } |
257 |
| - } |
258 |
| - //this.map.setFitView(zoomPoints); |
259 |
| - }, |
260 |
| - ConvertDMSToDD: function (degrees, minutes, seconds, direction) { |
261 |
| - var dd = degrees + minutes / 60 + seconds / (60 * 60); |
262 |
| - if (direction == "S" || direction == "W") { |
263 |
| - dd = dd * -1; |
264 |
| - } // Don't do anything for N or E |
265 |
| - return dd; |
266 |
| - }, |
267 |
| - renderPoint: function (lon, lat, GPSLongitudeRef, GPSLatitudeRef) { |
268 |
| - var x = this.ConvertDMSToDD(+ lon[0], + lon[1], + lon[2], GPSLongitudeRef); |
269 |
| - var y = this.ConvertDMSToDD(+ lat[0], + lat[1], + lat[2], GPSLatitudeRef); |
270 |
| - return {x, y}; |
271 |
| - }, |
272 |
| - renderPictureDetail: function (obj) { |
273 |
| - console.log('orenderPictureDetailbj: ', obj); |
274 |
| - this.picDetail.innerHTML = ''; |
275 |
| - var detailFields = { |
276 |
| - DateTimeOriginal: "拍摄时间", |
277 |
| - Make: "品牌", |
278 |
| - Model: "型号" |
279 |
| - }; |
280 |
| - for (var field in detailFields) { |
281 |
| - this.dumpDetail(detailFields[field], EXIF.getTag(obj, field)); |
282 |
| - } |
283 |
| - }, |
284 |
| - dumpDetail: function (name, value) { |
285 |
| - var div = document.createElement('div'); |
286 |
| - div.innerHTML = ` |
287 |
| - <em>${name}<em>:<span>${value}</span> |
288 |
| - `; |
289 |
| - this |
290 |
| - .picDetail |
291 |
| - .appendChild(div); |
292 |
| - console.log('this.picDetail: ', this.picDetail); |
293 |
| - } |
294 |
| - }; |
295 |
| - function initializegooglemap() { |
296 |
| - pageControl.init(); |
297 |
| - } |
298 |
| - pageControl.init(); |
299 |
| -</script> |
| 90 | +<script src="/resource/2021/1117_gps.js"> |
| 91 | +</script> |
0 commit comments