@heycar/heycars-map 0.9.14 → 0.9.15

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/dist/index.cjs CHANGED
@@ -12,7 +12,7 @@ if (typeof window !== "undefined" && typeof globalThis === "undefined") {
12
12
  window.globalThis = window;
13
13
  }
14
14
  const name = "@heycar/heycars-map";
15
- const version = "0.9.14";
15
+ const version = "0.9.15";
16
16
  const type = "module";
17
17
  const bin = {
18
18
  checkVersion: "./bin/checkVersion.js"
@@ -1343,11 +1343,11 @@ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
1343
1343
  return { timestamp, coords };
1344
1344
  };
1345
1345
  const alipayMyGetLocationSuccessResponse2GeolocationPosition = (res) => {
1346
- const { longitude, latitude, accuracy, altitude } = res;
1346
+ const { longitude, latitude, accuracy } = res;
1347
1347
  const timestamp = Date.now();
1348
1348
  const coords = {
1349
1349
  accuracy: Number(accuracy),
1350
- altitude: Number(altitude),
1350
+ altitude: null,
1351
1351
  altitudeAccuracy: null,
1352
1352
  heading: null,
1353
1353
  latitude: Number(latitude),
@@ -4243,7 +4243,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
4243
4243
  unwatchVisibilityState();
4244
4244
  };
4245
4245
  }
4246
- function alipayWatchPosition(onSuccess, onError, option) {
4246
+ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
4247
4247
  let enable = true;
4248
4248
  let prevGeoPosition = void 0;
4249
4249
  const { timeout = ALIPAY_GEO_CACHE_TIMEOUT } = option;
@@ -4256,7 +4256,7 @@ function alipayWatchPosition(onSuccess, onError, option) {
4256
4256
  continue;
4257
4257
  }
4258
4258
  const geoPosition = await new Promise((resolve) => {
4259
- my.getLocation({
4259
+ getLocationFn({
4260
4260
  type: 0,
4261
4261
  cacheTimeout: timeout / 1e3,
4262
4262
  success(res) {
@@ -4291,6 +4291,10 @@ function alipayWatchPosition(onSuccess, onError, option) {
4291
4291
  unwatchVisibilityState();
4292
4292
  };
4293
4293
  }
4294
+ const apGetLocation = ({ type: type2, cacheTimeout, success, fail }) => {
4295
+ const apType = type2 >= 2 ? 0 : type2 === 0 ? 2 : 1;
4296
+ ap.getLocation({ type: apType, cacheTimeout }).then(success).catch(fail);
4297
+ };
4294
4298
  function androidWatchPosition(onSuccess, onError, option) {
4295
4299
  let enable = true;
4296
4300
  let prevGeoPosition = void 0;
@@ -4347,8 +4351,11 @@ function compatibleWathPosition(onSuccess, onError, option) {
4347
4351
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4348
4352
  return wechatWatchPosition(onSuccess, onError, option);
4349
4353
  }
4354
+ if (browserPlatform === BRWOSER_PLATFORM.ALIPAY && osPlatform === OS_PLATFORM.IOS && typeof ap !== "undefined") {
4355
+ return alipayWatchPosition(onSuccess, onError, option, apGetLocation);
4356
+ }
4350
4357
  if (browserPlatform === BRWOSER_PLATFORM.ALIPAY || browserPlatform == BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM) {
4351
- return alipayWatchPosition(onSuccess, onError, option);
4358
+ return alipayWatchPosition(onSuccess, onError, option, (props) => my.getLocation(props));
4352
4359
  }
4353
4360
  if (osPlatform === OS_PLATFORM.ANDROID) {
4354
4361
  return androidWatchPosition(onSuccess, onError, option);
@@ -4434,9 +4441,9 @@ const useGeoLocation = (props) => {
4434
4441
  var _a, _b;
4435
4442
  const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
4436
4443
  const { toGcj02 } = useMapGCJ02();
4437
- const isIOSAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
4444
+ const isAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
4438
4445
  detectBrowserPlatform()
4439
- ) && detectOSPlatform() === OS_PLATFORM.IOS;
4446
+ );
4440
4447
  let isOnLoadTriggered = false;
4441
4448
  const loading = Vue.ref(false);
4442
4449
  const readyRef = Vue.ref(false);
@@ -4462,7 +4469,7 @@ const useGeoLocation = (props) => {
4462
4469
  spaceLog("watchPosition", "success duration, position = ", duration, position);
4463
4470
  const coordinate = position.coords;
4464
4471
  const wgsPoint = [position.coords.longitude, position.coords.latitude];
4465
- const point = isIOSAlipay ? wgsPoint : await toGcj02(wgsPoint);
4472
+ const point = isAlipay ? wgsPoint : await toGcj02(wgsPoint);
4466
4473
  coordinateRef.value = coordinate;
4467
4474
  positionRef.value = point;
4468
4475
  errorRef.value = void 0;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ if (typeof window !== "undefined" && typeof globalThis === "undefined") {
10
10
  window.globalThis = window;
11
11
  }
12
12
  const name = "@heycar/heycars-map";
13
- const version = "0.9.14";
13
+ const version = "0.9.15";
14
14
  const type = "module";
15
15
  const bin = {
16
16
  checkVersion: "./bin/checkVersion.js"
@@ -1341,11 +1341,11 @@ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
1341
1341
  return { timestamp, coords };
1342
1342
  };
1343
1343
  const alipayMyGetLocationSuccessResponse2GeolocationPosition = (res) => {
1344
- const { longitude, latitude, accuracy, altitude } = res;
1344
+ const { longitude, latitude, accuracy } = res;
1345
1345
  const timestamp = Date.now();
1346
1346
  const coords = {
1347
1347
  accuracy: Number(accuracy),
1348
- altitude: Number(altitude),
1348
+ altitude: null,
1349
1349
  altitudeAccuracy: null,
1350
1350
  heading: null,
1351
1351
  latitude: Number(latitude),
@@ -4241,7 +4241,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
4241
4241
  unwatchVisibilityState();
4242
4242
  };
4243
4243
  }
4244
- function alipayWatchPosition(onSuccess, onError, option) {
4244
+ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
4245
4245
  let enable = true;
4246
4246
  let prevGeoPosition = void 0;
4247
4247
  const { timeout = ALIPAY_GEO_CACHE_TIMEOUT } = option;
@@ -4254,7 +4254,7 @@ function alipayWatchPosition(onSuccess, onError, option) {
4254
4254
  continue;
4255
4255
  }
4256
4256
  const geoPosition = await new Promise((resolve) => {
4257
- my.getLocation({
4257
+ getLocationFn({
4258
4258
  type: 0,
4259
4259
  cacheTimeout: timeout / 1e3,
4260
4260
  success(res) {
@@ -4289,6 +4289,10 @@ function alipayWatchPosition(onSuccess, onError, option) {
4289
4289
  unwatchVisibilityState();
4290
4290
  };
4291
4291
  }
4292
+ const apGetLocation = ({ type: type2, cacheTimeout, success, fail }) => {
4293
+ const apType = type2 >= 2 ? 0 : type2 === 0 ? 2 : 1;
4294
+ ap.getLocation({ type: apType, cacheTimeout }).then(success).catch(fail);
4295
+ };
4292
4296
  function androidWatchPosition(onSuccess, onError, option) {
4293
4297
  let enable = true;
4294
4298
  let prevGeoPosition = void 0;
@@ -4345,8 +4349,11 @@ function compatibleWathPosition(onSuccess, onError, option) {
4345
4349
  if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
4346
4350
  return wechatWatchPosition(onSuccess, onError, option);
4347
4351
  }
4352
+ if (browserPlatform === BRWOSER_PLATFORM.ALIPAY && osPlatform === OS_PLATFORM.IOS && typeof ap !== "undefined") {
4353
+ return alipayWatchPosition(onSuccess, onError, option, apGetLocation);
4354
+ }
4348
4355
  if (browserPlatform === BRWOSER_PLATFORM.ALIPAY || browserPlatform == BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM) {
4349
- return alipayWatchPosition(onSuccess, onError, option);
4356
+ return alipayWatchPosition(onSuccess, onError, option, (props) => my.getLocation(props));
4350
4357
  }
4351
4358
  if (osPlatform === OS_PLATFORM.ANDROID) {
4352
4359
  return androidWatchPosition(onSuccess, onError, option);
@@ -4432,9 +4439,9 @@ const useGeoLocation = (props) => {
4432
4439
  var _a, _b;
4433
4440
  const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
4434
4441
  const { toGcj02 } = useMapGCJ02();
4435
- const isIOSAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
4442
+ const isAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
4436
4443
  detectBrowserPlatform()
4437
- ) && detectOSPlatform() === OS_PLATFORM.IOS;
4444
+ );
4438
4445
  let isOnLoadTriggered = false;
4439
4446
  const loading = ref(false);
4440
4447
  const readyRef = ref(false);
@@ -4460,7 +4467,7 @@ const useGeoLocation = (props) => {
4460
4467
  spaceLog("watchPosition", "success duration, position = ", duration, position);
4461
4468
  const coordinate = position.coords;
4462
4469
  const wgsPoint = [position.coords.longitude, position.coords.latitude];
4463
- const point = isIOSAlipay ? wgsPoint : await toGcj02(wgsPoint);
4470
+ const point = isAlipay ? wgsPoint : await toGcj02(wgsPoint);
4464
4471
  coordinateRef.value = coordinate;
4465
4472
  positionRef.value = point;
4466
4473
  errorRef.value = void 0;
@@ -0,0 +1,16 @@
1
+ export interface AlipayApGetLocationProps {
2
+ cacheTimeout?: number;
3
+ type?: number;
4
+ }
5
+ export interface AlipayApGetLocationSuccessResponse {
6
+ longitude: number;
7
+ latitude: number;
8
+ accuracy: number;
9
+ }
10
+ export interface AlipayApErrorResponse {
11
+ error: number;
12
+ errorMessage: string;
13
+ }
14
+ export interface AlipayAp {
15
+ getLocation: (props: AlipayApGetLocationProps) => Promise<AlipayApGetLocationSuccessResponse>;
16
+ }
@@ -2,7 +2,7 @@ export interface AlipayMyGetLocationSuccessResponse {
2
2
  longitude: number;
3
3
  latitude: number;
4
4
  accuracy: number;
5
- altitude: number;
5
+ altitude?: number;
6
6
  }
7
7
  export interface AlipayMyErrorResponse {
8
8
  error: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js"