index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. (() => {
  2. // 初始地图
  3. const initMap = (map) => {
  4. return {
  5. map,
  6. async loadImage(args) {
  7. const { file, minWidth, minHeight } = args
  8. args.img = args.img
  9. ? args.img
  10. : await blobImageLoad(file, minWidth, minHeight)
  11. return loadImageLayer(map, args)
  12. },
  13. screenToLatlan({x, y}) {
  14. const real = map.getCoordinateFromPixel([x, y])
  15. const latlan = ol.proj.transform(real,'EPSG:3857','EPSG:4326')
  16. return latlan
  17. }
  18. }
  19. }
  20. const loadImageLayer = (map, args) => {
  21. const {
  22. lon,
  23. lat
  24. } = args
  25. const itude = ol.proj.fromLonLat([lon, lat])
  26. const { image: imageLayer, canvas } = loadImage(map, args, itude)
  27. map.addLayer(imageLayer);
  28. map.getView().setCenter(
  29. ol.proj.fromLonLat([lon, lat])
  30. );
  31. map.getView().setZoom(19)
  32. return canvas
  33. }
  34. // 经纬度转canvas坐标
  35. const itudeToCanvasPos = (map, extent, itude) => {
  36. //Canvas四至范围不同于当前地图四至范围,计算出南北方向与东西方向的偏移
  37. const mapExtent = map.getView()
  38. .calculateExtent(map.getSize())
  39. //当前底图视图范围的投影坐标
  40. const canvasOrigin = map.getPixelFromCoordinate(
  41. [ extent[0], extent[3] ]
  42. );
  43. //添加到地图上的canvas图像的左上角
  44. const mapOrigin = map.getPixelFromCoordinate(
  45. [ mapExtent[0], mapExtent[3] ]
  46. );
  47. const delta = [
  48. mapOrigin[0] - canvasOrigin[0],
  49. mapOrigin[1] - canvasOrigin[1]
  50. ];
  51. const leftTop = map.getPixelFromCoordinate(itude)
  52. return {
  53. x: leftTop[0] + delta[0],
  54. y: leftTop[1] + delta[1]
  55. }
  56. }
  57. // 平移,旋转,放大当前canvas
  58. const transformCanvasCall = (
  59. canvas,
  60. transform,
  61. oper,
  62. center = {
  63. x: 0,
  64. y: 0
  65. }
  66. ) => {
  67. const ctx = canvas.getContext('2d')
  68. const {
  69. translate,
  70. scale,
  71. rotate
  72. } = transform
  73. ctx.translate(center.x, center.y)
  74. translate && ctx.translate(translate.x, translate.y)
  75. rotate && ctx.rotate(rotate * (Math.PI / 180))
  76. scale && ctx.scale(scale[0], scale[1])
  77. oper && oper()
  78. // scale && ctx.scale(1 / scale, 1 / scale)
  79. // rotate && ctx.rotate(-rotate * (Math.PI / 180))
  80. // translate && ctx.translate(-translate.x, -translate.y)
  81. ctx.translate(-center.x, -center.y)
  82. }
  83. const genImgCanvasItudeToReal = (map, canvas, extent) =>
  84. (itude) => {
  85. return genImgCanvasPosToReal(map, canvas)(
  86. itudeToCanvasPos(map, extent, itude)
  87. )
  88. }
  89. const genImgCanvasPosToReal = (map, canvas) =>
  90. (pos) => {
  91. const $real = map.getViewport()
  92. const offsetWidth = (canvas.width - $real.offsetWidth) / 2
  93. const offsetHeight = (canvas.height - $real.offsetHeight) / 2
  94. return {
  95. x: pos.x - offsetWidth,
  96. y: pos.y - offsetHeight
  97. }
  98. }
  99. const genImgCanvasTransfrom = (canvas, arrayImgs, scale, initPos) =>
  100. (transform) => {
  101. const ctx = canvas.getContext('2d');
  102. const dscale = transform.scale || [1, 1]
  103. const resize = 1 / (scale * 10)
  104. const doScale = [
  105. resize * dscale[0],
  106. resize * dscale[1]
  107. ]
  108. const imgData = { width: 0, height: 0 }
  109. arrayImgs.forEach(imgs => {
  110. let height = 0
  111. imgs.forEach(([img]) => height += img.height)
  112. imgData.width += imgs[0][0].width
  113. if (imgData.height < height) {
  114. imgData.height = height
  115. }
  116. })
  117. initPos.x -= imgData.width / 2
  118. initPos.y -= imgData.height / 2
  119. // , translate: { x: -(imgData.width / 2) * doScale[0], y: -(imgData.height / 2) * doScale[1] }
  120. ctx.fillStyle = 'rgba(0,0,0,0.1)'
  121. ctx.fillRect(0,0, canvas.width, canvas.height)
  122. transformCanvasCall(
  123. canvas,
  124. { ...transform, scale: doScale },
  125. () => {
  126. transform.draw && transform.draw(ctx)
  127. let width = 0
  128. arrayImgs.forEach(imgs => {
  129. let height = 0
  130. imgs.forEach(([img]) => {
  131. ctx.drawImage(img, width, height)
  132. height += img.height
  133. })
  134. width += imgs[0][0].width
  135. })
  136. },
  137. transform.center
  138. )
  139. const move = {
  140. x: transform.translate.x - initPos.x,
  141. y: transform.translate.y - initPos.y,
  142. }
  143. const start = {
  144. x: initPos.x + move.x,
  145. y: initPos.y + move.y,
  146. }
  147. const end = {
  148. x: start.x + imgData.width * doScale[0],
  149. y: start.y + imgData.height * doScale[1],
  150. }
  151. canvas.position = [
  152. start,
  153. end,
  154. Math.abs(start.x - end.x) / resize,
  155. Math.abs(start.y - end.y) / resize
  156. ]
  157. canvas.resize = resize
  158. canvas.imgData = imgData
  159. canvas.imgBox = [
  160. canvas.posToReal(start),
  161. canvas.posToReal(end),
  162. Math.abs(start.x - end.x),
  163. Math.abs(start.y - end.y)
  164. ]
  165. }
  166. // 加载url
  167. const loadImage = (map, args, itude) => {
  168. const canvas = document.createElement('canvas');
  169. const imageCanvas = new ol.source.ImageCanvas({
  170. canvasFunction(extent, scale, _2, size) {
  171. const pos = itudeToCanvasPos(map, extent, itude)
  172. const imgData = { width: 0, height: 0 }
  173. args.img.forEach(imgs => {
  174. let height = 0
  175. imgs.forEach(([img]) => height += img.height)
  176. imgData.width += imgs[0][0].width
  177. if (imgData.height < height) {
  178. imgData.height = height
  179. }
  180. })
  181. pos.x -= imgData.width / 2 * scale
  182. pos.y -= imgData.height / 2 * scale
  183. canvas.width = size[0];
  184. canvas.height = size[1]
  185. canvas.posToReal = genImgCanvasPosToReal(map, canvas);
  186. canvas.transform = genImgCanvasTransfrom(canvas, args.img, scale, pos, imageCanvas);
  187. canvas.itudeToReal = genImgCanvasItudeToReal(map, canvas, extent)
  188. canvas.transform({
  189. ...args,
  190. translate: {
  191. x: (args.translate ? args.translate.x : 0) + pos.x,
  192. y: (args.translate ? args.translate.y : 0) + pos.y
  193. }
  194. })
  195. return canvas;
  196. }
  197. })
  198. const image = new ol.layer.Image({ source: imageCanvas })
  199. canvas.imageLayer = imageCanvas
  200. return {
  201. image,
  202. canvas
  203. }
  204. }
  205. // 返回本地url
  206. const blobImageLoad = (arrayImages, minWidth, minHeight) => {
  207. console.log(arrayImages)
  208. const analysis = (blob) => new Promise((resolve, reject) => {
  209. const url = window.URL.createObjectURL(blob);
  210. const img = new Image()
  211. img.onload = () => {
  212. if (img.width < minWidth || img.height < minHeight) {
  213. reject('图片宽高需要大于512')
  214. } else {
  215. resolve([img, url, blob])
  216. }
  217. }
  218. img.src = url
  219. })
  220. let arrasPromises = []
  221. for (let images of arrayImages) {
  222. let analys = []
  223. for (let bolb of images) {
  224. analys.push(analysis(bolb))
  225. }
  226. arrasPromises.push(
  227. Promise.all(analys)
  228. )
  229. }
  230. return Promise.all(arrasPromises)
  231. }
  232. // 获取逆转矩阵
  233. const getCanvasInverImatrix = $canvas => {
  234. const ctx = $canvas.getContext('2d')
  235. const transform = ctx.getTransform()
  236. return transform.invertSelf();
  237. }
  238. // canvas坐标转屏幕坐标
  239. const getCanvasToScreenPos = ($canvas, {x, y}) => {
  240. const {
  241. a, b, c,
  242. d, e, f
  243. } = getCanvasInverImatrix($canvas)
  244. const screenX = (c * y - d * x + d * e - c * f) / (b * c - a * d)
  245. const screenY = (y - screenX * b - f) / d
  246. return {
  247. x: Math.round(screenX),
  248. y: Math.round(screenY),
  249. }
  250. }
  251. // 屏幕坐标转canvas坐标
  252. const getScreenToCanvasPos = ($canvas, {x, y}) => {
  253. const {
  254. a, b, c,
  255. d, e, f
  256. } = getCanvasInverImatrix($canvas)
  257. return {
  258. x: Math.round(x * a + y * c + e),
  259. y: Math.round(x * b + y * d + f)
  260. };
  261. }
  262. Vue.component('imageTranform', {
  263. props: ['mapOl'],
  264. name: 'imageTranform',
  265. template: `
  266. <div class="transform-layer" @mousemove.stop.prevent="move" @mouseup="upMove">
  267. <div class="upload-layer">
  268. 目录:<input type="file" @change="imageChange" directory webkitdirectory multiple>
  269. 单文件:<input type="file" @change="imageChange">
  270. </div>
  271. <div class="ctrls" :style="boxStyle" @mousedown.stop.prevent="startMove($event, 'move')"></div>
  272. <div class="cctrls" v-if="box.tl">
  273. <span class="tl" :style="{left: box.tl.x + 'px', top: box.tl.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'tl')"></span>
  274. <span class="tc" :style="{left: box.tc.x + 'px', top: box.tc.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'tc')"></span>
  275. <span class="tr" :style="{left: box.tr.x + 'px', top: box.tr.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'tr')"></span>
  276. <span class="rc" :style="{left: box.rc.x + 'px', top: box.rc.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'rc')"></span>
  277. <span class="lc" :style="{left: box.lc.x + 'px', top: box.lc.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'lc')"></span>
  278. <span class="br" :style="{left: box.br.x + 'px', top: box.br.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'br')"></span>
  279. <span class="bl" :style="{left: box.bl.x + 'px', top: box.bl.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'bl')"></span>
  280. <span class="bc" :style="{left: box.bc.x + 'px', top: box.bc.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'scale', 'bc')"></span>
  281. <span class="cc" :style="{left: box.cc.x + 'px', top: box.cc.y + 'px'}" @mousedown.prevent.stop="startMove($event, 'rotate')"></span>
  282. </div>
  283. <div class="box-info" v-if="boxPos.tl">
  284. <div v-for="(item, key) in boxPos" :key="key">
  285. <span>{{key}}</span>
  286. <span>{{item}}</span>
  287. </div>
  288. </div>
  289. </div>
  290. `,
  291. data() {
  292. return {
  293. isHover: false,
  294. box: {},
  295. left: 0,
  296. top: 0
  297. }
  298. },
  299. methods: {
  300. async imageChange(e) {
  301. let imagesArray = []
  302. if (e.target.files.length > 1) {
  303. const formatError = () => {
  304. e.target.value = null
  305. console.log(imagesXYZ)
  306. alert('目录不规范 请上传 z/x/y.png 格式目录,且在最底级目录放置图片文件')
  307. }
  308. let imagesXYZ = {}
  309. for (let file of e.target.files) {
  310. let locals = file.webkitRelativePath.split(/[\\|//]/)
  311. if (locals.length < 3) return formatError()
  312. let current = imagesXYZ
  313. for (let i = 0; i < locals.length; i++) {
  314. let dir = locals[i]
  315. if (i !== locals.length - 1) {
  316. if (!current[dir]) {
  317. current[dir] = i === locals.length - 2 ? [] : {}
  318. }
  319. current = current[dir]
  320. if (i === locals.length - 3) {
  321. current.key = 'z'
  322. }
  323. }
  324. if (i === locals.length - 1) {
  325. current.push(file)
  326. }
  327. }
  328. }
  329. (function analysis (updateXYZ) {
  330. if (updateXYZ.key === 'z') {
  331. imagesXYZ = updateXYZ
  332. return;
  333. }
  334. const names = Object.keys(updateXYZ).sort((a, b) => b - a)
  335. names.forEach(key => {
  336. if (key !== names[0]) {
  337. delete updateXYZ[key]
  338. }
  339. })
  340. analysis(updateXYZ[names[0]])
  341. })(imagesXYZ);
  342. if (!(imagesXYZ && imagesXYZ.key === 'z' && !Array.isArray(imagesXYZ))) {
  343. return formatError()
  344. }
  345. for (let key in imagesXYZ) {
  346. if (!Array.isArray(imagesXYZ[key]) && key !== 'key') {
  347. return formatError()
  348. }
  349. }
  350. delete imagesXYZ.key
  351. Object.keys(imagesXYZ).sort((a, b) => a - b).forEach(key => {
  352. imagesArray.push(
  353. imagesXYZ[key].sort((a, b) => parseInt(a.name) - parseInt(b))
  354. )
  355. })
  356. } else {
  357. imagesArray = [[e.target.files[0]]]
  358. }
  359. try {
  360. this.transfroms = []
  361. this.args = {
  362. draw: (ctx) => {
  363. this.transfroms.forEach(transform => {
  364. transform.forEach(({translate, scale, rotate, center}) => {
  365. // 设置绘制颜色
  366. center && ctx.translate(center.x, center.y)
  367. translate && ctx.translate(translate.x, translate.y)
  368. rotate && ctx.rotate(rotate * (Math.PI / 180))
  369. scale && ctx.scale(scale[0], scale[1])
  370. center && ctx.translate(-center.x, -center.y)
  371. // if (center) {
  372. // ctx.fillStyle = "geend";
  373. // // 绘制成矩形
  374. // ctx.fillRect(center.x, center.y, 100, 100);
  375. // }
  376. })
  377. })
  378. setTimeout(() => {
  379. this.updateBox(this.imgCanvas.imgBox)
  380. })
  381. },
  382. file: imagesArray,
  383. lon: 113.59963069739054,
  384. lat: 22.364821730960752,
  385. translate: {x: 0, y: 0},
  386. scale: [1, 1],
  387. direction: 0
  388. }
  389. console.log('---0---')
  390. this.imgCanvas = await this.map.loadImage(this.args)
  391. } catch(e) {
  392. alert(e)
  393. }
  394. },
  395. updateBox() {
  396. const calcPos = pos => getCanvasToScreenPos(this.imgCanvas, pos)
  397. this.box = {
  398. tl: this.imgCanvas.posToReal(calcPos({x: 0, y: 0})),
  399. tc: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width / 2, y: 0})),
  400. tr: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width, y: 0})),
  401. rc: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width, y: this.imgCanvas.imgData.height / 2})),
  402. lc: this.imgCanvas.posToReal(calcPos({x: 0, y: this.imgCanvas.imgData.height / 2})),
  403. br: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width, y: this.imgCanvas.imgData.height})),
  404. bl: this.imgCanvas.posToReal(calcPos({x: 0, y: this.imgCanvas.imgData.height})),
  405. bc: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width / 2, y: this.imgCanvas.imgData.height})),
  406. cc: this.imgCanvas.posToReal(calcPos({x: this.imgCanvas.imgData.width / 2, y: this.imgCanvas.imgData.height / 2})),
  407. }
  408. let maxX = this.box.tl.x
  409. let minX = this.box.tl.x
  410. let maxY = this.box.tl.y
  411. let minY = this.box.tl.y
  412. Object.values(this.box).forEach(({x, y}) => {
  413. x > maxX && (maxX = x)
  414. y > maxY && (maxY = y)
  415. x < minX && (minX = x)
  416. y < minY && (minY = y)
  417. })
  418. this.box.width = Math.abs(maxX - minX)
  419. this.box.height = Math.abs(maxY - minY)
  420. },
  421. mapStartHandle() {
  422. this.mapDown = true
  423. },
  424. moveHandle(e) {
  425. if (!this.imgCanvas || !this.imgCanvas.imgBox) {
  426. return;
  427. }
  428. if (this.moveing && this.oper) {
  429. this.move(e)
  430. } else {
  431. this.mapDown && this.imgCanvas.imageLayer.refresh()
  432. // const [start, end] = this.box
  433. // this.isHover = e.clientX > start.x && e.clientX < end.x &&
  434. // e.clientY > start.y && e.clientY < end.y
  435. }
  436. },
  437. startMove(ev, oper, dir) {
  438. this.startTransform = {
  439. ...this.args
  440. }
  441. this.transfroms.push([])
  442. this.moveing = true
  443. this.oper = oper
  444. this.dir = dir
  445. this.startMovePos = {
  446. x: ev.clientX,
  447. y: ev.clientY
  448. }
  449. },
  450. move(ev) {
  451. if (!this.moveing) return;
  452. const transfrom = this.transfroms[this.transfroms.length - 1]
  453. const start = getScreenToCanvasPos(
  454. this.imgCanvas,
  455. this.startMovePos
  456. )
  457. const end = getScreenToCanvasPos(
  458. this.imgCanvas,
  459. { x: ev.clientX, y: ev.clientY }
  460. )
  461. const move = {
  462. x: end.x - start.x,
  463. y: end.y - start.y
  464. }
  465. if (this.oper === 'move') {
  466. transfrom.push({ translate: move })
  467. } else if (this.oper === 'scale'){
  468. const width = this.imgCanvas.position[2]
  469. const height = this.imgCanvas.position[3]
  470. let xScale, yScale
  471. switch(this.dir) {
  472. case 'tl':
  473. xScale = (width - move.x) / width
  474. yScale = (height - move.y) / height
  475. if (xScale > 0.1 && yScale > 0.1) {
  476. transfrom.push({
  477. scale: [xScale, yScale],
  478. center: {x: this.imgCanvas.position[2], y: this.imgCanvas.position[3]}
  479. })
  480. }
  481. break;
  482. case 'tc':
  483. yScale = (height - move.y) / height
  484. if (yScale > 0.1) {
  485. transfrom.push({
  486. scale: [1, yScale],
  487. center: {x: 0, y: this.imgCanvas.position[3]}
  488. })
  489. }
  490. break;
  491. case 'tr':
  492. xScale = (width + move.x) / width
  493. yScale = (height - move.y) / height
  494. if (xScale > 0.1 && yScale > 0.1) {
  495. transfrom.push({
  496. scale: [xScale, yScale],
  497. center: {x: 0, y: this.imgCanvas.position[3]}
  498. })
  499. }
  500. break;
  501. case 'rc':
  502. xScale = (width + move.x) / width
  503. if (xScale > 0.1) {
  504. transfrom.push({
  505. scale: [xScale, 1],
  506. center: {x: 0, y: this.imgCanvas.position[3]}
  507. })
  508. }
  509. break;
  510. case 'lc':
  511. xScale = (width - move.x) / width
  512. if (xScale > 0.1) {
  513. transfrom.push({
  514. scale: [xScale, 1],
  515. center: {x: this.imgCanvas.position[2], y: this.imgCanvas.position[3]}
  516. })
  517. }
  518. break;
  519. case 'br':
  520. xScale = (width + move.x) / width
  521. yScale = (height + move.y) / height
  522. if (xScale > 0.1 && yScale > 0.1) {
  523. transfrom.push({
  524. scale: [xScale, yScale],
  525. center: {x: 0, y: 0}
  526. })
  527. }
  528. break;
  529. case 'bl':
  530. xScale = (width - move.x) / width
  531. yScale = (height + move.y) / height
  532. if (xScale > 0.1 && yScale > 0.1) {
  533. transfrom.push({
  534. scale: [xScale, yScale],
  535. center: {x: this.imgCanvas.position[2], y: 0}
  536. })
  537. }
  538. break;
  539. case 'bc':
  540. yScale = (height + move.y) / height
  541. if (yScale > 0.1) {
  542. transfrom.push({
  543. scale: [1, yScale],
  544. center: {x: 0, y: 0}
  545. })
  546. }
  547. break;
  548. }
  549. } else if (this.oper === 'rotate') {
  550. let move = ev.clientX - this.startMovePos.x
  551. let height = this.imgCanvas.position[3]
  552. let width = this.imgCanvas.position[2]
  553. let center = {x: width / 2, y: height / 2}
  554. // let zrotate = transfrom.
  555. transfrom.push({
  556. rotate: move / 3,
  557. center: center
  558. })
  559. }
  560. this.startMovePos = {
  561. x: ev.clientX,
  562. y: ev.clientY
  563. }
  564. this.imgCanvas.imageLayer.refresh()
  565. },
  566. upMove() {
  567. this.moveing = false
  568. this.mapDown = false
  569. this.oper = null
  570. this.dir = null
  571. this.startMovePos = null
  572. },
  573. getInfo() {
  574. return {
  575. pos: this.boxPos,
  576. img: this.args.img
  577. }
  578. }
  579. },
  580. computed: {
  581. boxStyle() {
  582. if (this.box && Object.keys(this.box).length) {
  583. const box = this.box
  584. return {
  585. width: box.width + 20 + 'px',
  586. height: box.height + 20 + 'px',
  587. left: box.cc.x + 'px',
  588. top: box.cc.y + 'px'
  589. }
  590. } else {
  591. return {}
  592. }
  593. },
  594. boxPos() {
  595. if (this.box && Object.keys(this.box).length) {
  596. const ret = {}
  597. for (let key in this.box) {
  598. if (key !== 'width' && key !== 'height') {
  599. ret[key] = this.map.screenToLatlan(this.box[key])
  600. }
  601. }
  602. return ret
  603. } else {
  604. return {}
  605. }
  606. }
  607. },
  608. mounted() {
  609. document.documentElement.addEventListener('mousemove', ev => {
  610. ev.stopPropagation()
  611. ev.preventDefault()
  612. this.moveHandle.bind(this)(ev)
  613. this.move.bind(this)(ev)
  614. })
  615. document.documentElement.addEventListener('mousedown', ev => {
  616. this.mapStartHandle.bind(this)(ev)
  617. })
  618. document.documentElement.addEventListener('mouseup', ev => {
  619. ev.stopPropagation()
  620. ev.preventDefault()
  621. this.upMove.bind(this)()
  622. })
  623. this.map = initMap(this.mapOl)
  624. }
  625. })
  626. })();