@mapcatch/util 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcatch/util",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "./dist/catchUtil.min.js",
5
5
  "repository": "",
6
6
  "author": "wanyanyan",
@@ -20,7 +20,7 @@ export const getData = function (img, callback) {
20
20
  getImageData(img, callback);
21
21
  } else {
22
22
  if (callback) {
23
- callback.call(img);
23
+ callback(img);
24
24
  }
25
25
  }
26
26
  return true;
@@ -38,7 +38,7 @@ function getImageData(img, callback) {
38
38
  img.xmpdata = xmpdata || {};
39
39
  }
40
40
  if (callback) {
41
- callback.call(img);
41
+ callback(img);
42
42
  }
43
43
  } catch (err) {
44
44
  callback(null, err)
package/src/util.js CHANGED
@@ -311,13 +311,13 @@ export function getLineLabelFeature(lineFeature) {
311
311
  midPoint.geometry.coordinates.push(((labelLine[0][2] || 0) + (labelLine[1][2] || 0)) / 2)
312
312
  return midPoint
313
313
  }
314
- export function project(lngLat) { // 经纬度转墨卡托像素坐标
314
+ export function project(lngLat, zoom=12) { // 经纬度转墨卡托像素坐标
315
315
  let [lng, lat] = lngLat
316
316
  let x = (180 + lng) / 360
317
317
  let y = (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360
318
318
  return {
319
- x: x * Math.pow(2, 12) * 512,
320
- y: y * Math.pow(2, 12) * 512
319
+ x: x * Math.pow(2, zoom) * 512,
320
+ y: y * Math.pow(2, zoom) * 512
321
321
  }
322
322
  }
323
323
  export function addIcons2Map (map, icons) {