@heycar/heycars-map 0.6.8 → 0.6.9

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
@@ -3129,6 +3129,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3129
3129
  let enable = true;
3130
3130
  let interval = WX_GET_LOCATION_INTERVAL_STILL;
3131
3131
  let prevGeoPosition = void 0;
3132
+ const isGeoWorkingRef = Vue.ref(true);
3132
3133
  const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
3133
3134
  const startWatch = async () => {
3134
3135
  await wxReady();
@@ -3137,7 +3138,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3137
3138
  await sleep$1(WX_GET_LOCATION_INTERVAL_FAST);
3138
3139
  continue;
3139
3140
  }
3140
- const geoPosition = await new Promise((resolve, reject) => {
3141
+ const geoPosition = await new Promise((resolve) => {
3141
3142
  let isHandled = false;
3142
3143
  wx.getLocation({
3143
3144
  type: "wgs84",
@@ -3145,6 +3146,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3145
3146
  if (isHandled)
3146
3147
  return;
3147
3148
  isHandled = true;
3149
+ isGeoWorkingRef.value = true;
3148
3150
  const speed = Number(res.speed);
3149
3151
  interval = speed === 0 ? WX_GET_LOCATION_INTERVAL_STILL : speed < 2 ? WX_GET_LOCATION_INTERVAL_SLOW : WX_GET_LOCATION_INTERVAL_FAST;
3150
3152
  resolve(wxGetLocationSuccessResponse2GeolocationPosition(res));
@@ -3153,9 +3155,13 @@ function wechatWatchPosition(onSuccess, onError, option) {
3153
3155
  if (isHandled)
3154
3156
  return;
3155
3157
  isHandled = true;
3156
- const error = new Error(res.errMsg);
3157
- reject(error);
3158
- onError == null ? void 0 : onError(error);
3158
+ const isGeoWorking = isGeoWorkingRef.value;
3159
+ isGeoWorkingRef.value = false;
3160
+ console.warn("MyWarning: wx.getLocation failed msg = ", res.errMsg);
3161
+ resolve(void 0);
3162
+ if (!isGeoWorking)
3163
+ return;
3164
+ onError == null ? void 0 : onError(new Error(res.errMsg));
3159
3165
  }
3160
3166
  });
3161
3167
  if (!timeout)
@@ -3286,7 +3292,7 @@ const useGeoLocation = (props) => {
3286
3292
  var _a, _b;
3287
3293
  const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
3288
3294
  const { toGcj02 } = useMapGCJ02();
3289
- let isOnLoadDefaultTriggered = false;
3295
+ let isOnLoadTriggered = false;
3290
3296
  const loading = Vue.ref(false);
3291
3297
  const readyRef = Vue.ref(false);
3292
3298
  const errorRef = Vue.ref();
@@ -3314,9 +3320,11 @@ const useGeoLocation = (props) => {
3314
3320
  const point = await toGcj02(wgsPoint);
3315
3321
  coordinateRef.value = coordinate;
3316
3322
  positionRef.value = point;
3323
+ errorRef.value = void 0;
3317
3324
  if (loading.value) {
3318
3325
  loading.value = false;
3319
3326
  readyRef.value = true;
3327
+ isOnLoadTriggered = true;
3320
3328
  onLoad == null ? void 0 : onLoad({ position: point, coordinate });
3321
3329
  }
3322
3330
  onChange == null ? void 0 : onChange({ position: point, coordinate });
@@ -3326,8 +3334,8 @@ const useGeoLocation = (props) => {
3326
3334
  loading.value = false;
3327
3335
  errorRef.value = error;
3328
3336
  const position = props == null ? void 0 : props.geoDefaultPosition;
3329
- if (position && !isOnLoadDefaultTriggered) {
3330
- isOnLoadDefaultTriggered = true;
3337
+ if (position && !isOnLoadTriggered) {
3338
+ isOnLoadTriggered = true;
3331
3339
  onLoadDefault == null ? void 0 : onLoadDefault({ position });
3332
3340
  }
3333
3341
  onError == null ? void 0 : onError(error);
package/dist/index.js CHANGED
@@ -3127,6 +3127,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3127
3127
  let enable = true;
3128
3128
  let interval = WX_GET_LOCATION_INTERVAL_STILL;
3129
3129
  let prevGeoPosition = void 0;
3130
+ const isGeoWorkingRef = ref(true);
3130
3131
  const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
3131
3132
  const startWatch = async () => {
3132
3133
  await wxReady();
@@ -3135,7 +3136,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3135
3136
  await sleep$1(WX_GET_LOCATION_INTERVAL_FAST);
3136
3137
  continue;
3137
3138
  }
3138
- const geoPosition = await new Promise((resolve, reject) => {
3139
+ const geoPosition = await new Promise((resolve) => {
3139
3140
  let isHandled = false;
3140
3141
  wx.getLocation({
3141
3142
  type: "wgs84",
@@ -3143,6 +3144,7 @@ function wechatWatchPosition(onSuccess, onError, option) {
3143
3144
  if (isHandled)
3144
3145
  return;
3145
3146
  isHandled = true;
3147
+ isGeoWorkingRef.value = true;
3146
3148
  const speed = Number(res.speed);
3147
3149
  interval = speed === 0 ? WX_GET_LOCATION_INTERVAL_STILL : speed < 2 ? WX_GET_LOCATION_INTERVAL_SLOW : WX_GET_LOCATION_INTERVAL_FAST;
3148
3150
  resolve(wxGetLocationSuccessResponse2GeolocationPosition(res));
@@ -3151,9 +3153,13 @@ function wechatWatchPosition(onSuccess, onError, option) {
3151
3153
  if (isHandled)
3152
3154
  return;
3153
3155
  isHandled = true;
3154
- const error = new Error(res.errMsg);
3155
- reject(error);
3156
- onError == null ? void 0 : onError(error);
3156
+ const isGeoWorking = isGeoWorkingRef.value;
3157
+ isGeoWorkingRef.value = false;
3158
+ console.warn("MyWarning: wx.getLocation failed msg = ", res.errMsg);
3159
+ resolve(void 0);
3160
+ if (!isGeoWorking)
3161
+ return;
3162
+ onError == null ? void 0 : onError(new Error(res.errMsg));
3157
3163
  }
3158
3164
  });
3159
3165
  if (!timeout)
@@ -3284,7 +3290,7 @@ const useGeoLocation = (props) => {
3284
3290
  var _a, _b;
3285
3291
  const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
3286
3292
  const { toGcj02 } = useMapGCJ02();
3287
- let isOnLoadDefaultTriggered = false;
3293
+ let isOnLoadTriggered = false;
3288
3294
  const loading = ref(false);
3289
3295
  const readyRef = ref(false);
3290
3296
  const errorRef = ref();
@@ -3312,9 +3318,11 @@ const useGeoLocation = (props) => {
3312
3318
  const point = await toGcj02(wgsPoint);
3313
3319
  coordinateRef.value = coordinate;
3314
3320
  positionRef.value = point;
3321
+ errorRef.value = void 0;
3315
3322
  if (loading.value) {
3316
3323
  loading.value = false;
3317
3324
  readyRef.value = true;
3325
+ isOnLoadTriggered = true;
3318
3326
  onLoad == null ? void 0 : onLoad({ position: point, coordinate });
3319
3327
  }
3320
3328
  onChange == null ? void 0 : onChange({ position: point, coordinate });
@@ -3324,8 +3332,8 @@ const useGeoLocation = (props) => {
3324
3332
  loading.value = false;
3325
3333
  errorRef.value = error;
3326
3334
  const position = props == null ? void 0 : props.geoDefaultPosition;
3327
- if (position && !isOnLoadDefaultTriggered) {
3328
- isOnLoadDefaultTriggered = true;
3335
+ if (position && !isOnLoadTriggered) {
3336
+ isOnLoadTriggered = true;
3329
3337
  onLoadDefault == null ? void 0 : onLoadDefault({ position });
3330
3338
  }
3331
3339
  onError == null ? void 0 : onError(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",