@heycar/heycars-map 0.6.4 → 0.6.6

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
@@ -884,8 +884,8 @@ createComparator(function() {
884
884
  createComparator(createCircularEqualCreator());
885
885
  createComparator(createCircularEqualCreator(sameValueZeroEqual));
886
886
  const vec2lnglat = ([lng, lat]) => ({
887
- lng,
888
- lat
887
+ lng: Number(lng),
888
+ lat: Number(lat)
889
889
  });
890
890
  const decodeAsterisk = (encodedValue) => {
891
891
  const result = [];
@@ -912,7 +912,7 @@ const language2vectorMapForeign = (lang) => {
912
912
  return "style_zh_cn";
913
913
  }
914
914
  };
915
- const place2point = (place) => [place.lng, place.lat];
915
+ const place2point = (place) => [Number(place.lng), Number(place.lat)];
916
916
  const pipeAsync = (fn) => (...args) => {
917
917
  Promise.resolve().then(() => fn == null ? void 0 : fn(...args));
918
918
  };
@@ -943,6 +943,35 @@ const isPlaceEqual = (p1, p2) => {
943
943
  const isPointEqual = (p1, p2) => {
944
944
  return p1[0] === (p2 == null ? void 0 : p2[0]) && p1[1] === (p2 == null ? void 0 : p2[1]);
945
945
  };
946
+ const isGeoPositionEqual = (p1, p2) => {
947
+ if (!p2)
948
+ return false;
949
+ return p1.coords.longitude === p2.coords.longitude && p1.coords.latitude === p2.coords.latitude;
950
+ };
951
+ const toPlaceType = (maybePlace) => {
952
+ const lng = Number(maybePlace.lng);
953
+ if (isNaN(lng))
954
+ throw new Error("MyError: expect lng to be number");
955
+ const lat = Number(maybePlace.lat);
956
+ if (isNaN(lat))
957
+ throw new Error("MyError: expect lat to be number");
958
+ return { lng, lat, name: maybePlace.name };
959
+ };
960
+ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
961
+ const { longitude, latitude, accuracy } = res;
962
+ const speed = Number(res.speed);
963
+ const timestamp = Date.now();
964
+ const coords = {
965
+ accuracy: Number(accuracy),
966
+ altitude: null,
967
+ altitudeAccuracy: null,
968
+ heading: null,
969
+ latitude: Number(latitude),
970
+ longitude: Number(longitude),
971
+ speed
972
+ };
973
+ return { timestamp, coords };
974
+ };
946
975
  const deepCompareEqualsForMaps = createComparator((deepEqual) => (a, b) => {
947
976
  if (isLatLngLiteral(a) || isLatLngLiteral(b)) {
948
977
  return new google.maps.LatLng(a).equals(new google.maps.LatLng(b));
@@ -2213,12 +2242,12 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2213
2242
  "attrs": {
2214
2243
  "mapRef": setMap,
2215
2244
  "mapId": gmapId,
2216
- "center": center ? vec2lnglat(center.map(Number)) : void 0,
2245
+ "center": center ? vec2lnglat(center) : void 0,
2217
2246
  "zoom": zoom,
2218
2247
  "disableDefaultUI": true,
2219
2248
  "clickableIcons": false,
2220
2249
  "disableDoubleClickZoom": touchEnable,
2221
- "gestureHandling": touchEnable ? "auto" : "none",
2250
+ "gestureHandling": touchEnable ? "greedy" : "none",
2222
2251
  "keyboardShortcuts": touchEnable,
2223
2252
  "touchZoomCenter": touchZoomCenter
2224
2253
  },
@@ -3027,6 +3056,90 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3027
3056
  })]);
3028
3057
  };
3029
3058
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3059
+ const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3060
+ const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3061
+ const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
3062
+ const takeIsForceBrowserGeo = () => {
3063
+ const searchParam = new URLSearchParams(location.search);
3064
+ return searchParam.has(`force-browser-geo`);
3065
+ };
3066
+ const sleep$1 = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
3067
+ const wxReady = () => new Promise((resolve, reject) => {
3068
+ wx.ready(resolve);
3069
+ wx.error(reject);
3070
+ });
3071
+ const detectPlatform = () => {
3072
+ const useragent = navigator.userAgent.toLowerCase();
3073
+ if (useragent.includes("micromessenger"))
3074
+ return "wechat";
3075
+ if (useragent.includes("alipay"))
3076
+ return "alipay";
3077
+ return "other";
3078
+ };
3079
+ function wechatWatchPosition(onSuccess, onError, option) {
3080
+ const { timeout } = option;
3081
+ let enable = true;
3082
+ let interval = WX_GET_LOCATION_INTERVAL_STILL;
3083
+ let prevGeoPosition = void 0;
3084
+ const startWatch = async () => {
3085
+ await wxReady();
3086
+ do {
3087
+ const geoPosition = await new Promise((resolve, reject) => {
3088
+ let isHandled = false;
3089
+ wx.getLocation({
3090
+ type: "wgs84",
3091
+ success(res) {
3092
+ if (isHandled)
3093
+ return;
3094
+ isHandled = true;
3095
+ const speed = Number(res.speed);
3096
+ interval = speed === 0 ? WX_GET_LOCATION_INTERVAL_STILL : speed < 2 ? WX_GET_LOCATION_INTERVAL_SLOW : WX_GET_LOCATION_INTERVAL_FAST;
3097
+ resolve(wxGetLocationSuccessResponse2GeolocationPosition(res));
3098
+ },
3099
+ fail(res) {
3100
+ if (isHandled)
3101
+ return;
3102
+ isHandled = true;
3103
+ const error = new Error(res.errMsg);
3104
+ reject(error);
3105
+ onError == null ? void 0 : onError(error);
3106
+ }
3107
+ });
3108
+ if (!timeout)
3109
+ return;
3110
+ setTimeout(() => {
3111
+ if (isHandled)
3112
+ return;
3113
+ interval = WX_GET_LOCATION_INTERVAL_SLOW;
3114
+ resolve(void 0);
3115
+ }, timeout);
3116
+ });
3117
+ if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
3118
+ onSuccess(geoPosition);
3119
+ prevGeoPosition = geoPosition;
3120
+ await sleep$1(interval);
3121
+ } while (enable);
3122
+ };
3123
+ startWatch();
3124
+ return () => {
3125
+ enable = false;
3126
+ };
3127
+ }
3128
+ function compatibleWathPosition(onSuccess, onError, option) {
3129
+ const isForceBrowserGeo = takeIsForceBrowserGeo();
3130
+ if (isForceBrowserGeo) {
3131
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3132
+ return () => navigator.geolocation.clearWatch(watchId);
3133
+ }
3134
+ switch (detectPlatform()) {
3135
+ case "wechat":
3136
+ return wechatWatchPosition(onSuccess, onError, option);
3137
+ default: {
3138
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3139
+ return () => navigator.geolocation.clearWatch(watchId);
3140
+ }
3141
+ }
3142
+ }
3030
3143
  const isPlace = (place) => {
3031
3144
  return place.lng !== void 0 && place.lat !== void 0;
3032
3145
  };
@@ -3046,7 +3159,7 @@ class SingleGeoWatch {
3046
3159
  __publicField(this, "id", 0);
3047
3160
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
3048
3161
  __publicField(this, "option", {});
3049
- __publicField(this, "singleWatchId");
3162
+ __publicField(this, "unwatch");
3050
3163
  this.option = option != null ? option : {};
3051
3164
  }
3052
3165
  watchPosition(onSuccess, onError) {
@@ -3060,12 +3173,12 @@ class SingleGeoWatch {
3060
3173
  this.listeners.delete(id);
3061
3174
  }
3062
3175
  async start() {
3063
- const { listeners, option, singleWatchId } = this;
3064
- if (singleWatchId) {
3065
- navigator.geolocation.clearWatch(singleWatchId);
3176
+ const { listeners, option, unwatch } = this;
3177
+ if (unwatch) {
3178
+ unwatch();
3066
3179
  await sleep(20);
3067
3180
  }
3068
- this.singleWatchId = navigator.geolocation.watchPosition(
3181
+ this.unwatch = compatibleWathPosition(
3069
3182
  (position) => {
3070
3183
  for (const [onSuccess] of listeners.values()) {
3071
3184
  onSuccess(position);
@@ -3136,10 +3249,12 @@ const useGeoLocation = (props) => {
3136
3249
  Vue.watch(
3137
3250
  () => true,
3138
3251
  (_1, _2, onCleanup) => {
3252
+ const logStartTime = Date.now();
3139
3253
  loading.value = true;
3140
3254
  const watchId = singleGeoWatch.watchPosition(
3141
3255
  async (position) => {
3142
- console.log("watchPosition success position = ", position);
3256
+ const duration = Date.now() - logStartTime;
3257
+ spaceLog("watchPosition", "success duration, position = ", duration, position);
3143
3258
  const coordinate = position.coords;
3144
3259
  const wgsPoint = [position.coords.longitude, position.coords.latitude];
3145
3260
  const point = await toGcj02(wgsPoint);
@@ -3153,7 +3268,7 @@ const useGeoLocation = (props) => {
3153
3268
  onChange == null ? void 0 : onChange({ position: point, coordinate });
3154
3269
  },
3155
3270
  (error) => {
3156
- console.log("watchPosition error = ", error);
3271
+ spaceLog("watchPosition", "error.message = ", error.message);
3157
3272
  loading.value = false;
3158
3273
  errorRef.value = error;
3159
3274
  const position = props == null ? void 0 : props.geoDefaultPosition;
@@ -3948,8 +4063,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3948
4063
  centerSource.source = "api";
3949
4064
  updatePlace(point);
3950
4065
  };
3951
- const setCenterPlaceByUserSpecified = async (place) => {
4066
+ const setCenterPlaceByUserSpecified = async (input) => {
3952
4067
  centerSource.source = "api";
4068
+ const place = toPlaceType(input);
3953
4069
  centerPlace.lng = place.lng;
3954
4070
  centerPlace.lat = place.lat;
3955
4071
  centerPlace.name = place.name;
@@ -3975,14 +4091,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3975
4091
  } = useGeoLocation({
3976
4092
  geoDefaultPosition,
3977
4093
  onLoad: async (value) => {
3978
- console.log("useGeoLocation onLoad value = ", value);
3979
4094
  await readyPromise;
3980
4095
  centerSource.source = "geo";
3981
4096
  updatePlace(value.position);
3982
4097
  emit("loadGeoLocation", value);
3983
4098
  },
3984
4099
  onLoadDefault: async (value) => {
3985
- console.log("useGeoLocation onLoadDefault value = ", value);
3986
4100
  await readyPromise;
3987
4101
  const place = await defaultCenterPlacePromise;
3988
4102
  centerSource.source = "geo";
@@ -4076,7 +4190,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4076
4190
  } = props;
4077
4191
  const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
4078
4192
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
4079
- console.log("BusinessRecomendPlaceMap render geoLoading, isFirstWorkflowRecomendLoadingRef = ", geoLoading.value, isFirstWorkflowRecomendLoadingRef.value);
4080
4193
  return Vue.h(HeycarMap, {
4081
4194
  "attrs": {
4082
4195
  "center": centerPoint.value,
@@ -5011,10 +5124,12 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
5011
5124
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
5012
5125
  return () => {
5013
5126
  const {
5014
- from,
5015
- to
5127
+ from: inputFrom,
5128
+ to: inputTo
5016
5129
  } = props;
5017
- const isReady = isPlace(from) && isPlace(to);
5130
+ const isReady = isPlace(inputFrom) && isPlace(inputTo);
5131
+ const from = toPlaceType(inputFrom);
5132
+ const to = toPlaceType(inputTo);
5018
5133
  const center = isReady ? place2point(from) : [...BEIJIN_POINT];
5019
5134
  return Vue.h(HeycarMap, {
5020
5135
  "attrs": {
@@ -5078,12 +5193,14 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5078
5193
  return () => {
5079
5194
  const {
5080
5195
  driverStatus,
5081
- from,
5082
- to,
5196
+ from: inputFrom,
5197
+ to: inputTo,
5083
5198
  dispatchingTitle,
5084
5199
  bookDispatchingTitle,
5085
5200
  driverArrivedTitle
5086
5201
  } = props;
5202
+ const from = toPlaceType(inputFrom);
5203
+ const to = toPlaceType(inputTo);
5087
5204
  const carPosition = carPositionRef.value;
5088
5205
  const carAngle = carAngleRef.value;
5089
5206
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
package/dist/index.js CHANGED
@@ -882,8 +882,8 @@ createComparator(function() {
882
882
  createComparator(createCircularEqualCreator());
883
883
  createComparator(createCircularEqualCreator(sameValueZeroEqual));
884
884
  const vec2lnglat = ([lng, lat]) => ({
885
- lng,
886
- lat
885
+ lng: Number(lng),
886
+ lat: Number(lat)
887
887
  });
888
888
  const decodeAsterisk = (encodedValue) => {
889
889
  const result = [];
@@ -910,7 +910,7 @@ const language2vectorMapForeign = (lang) => {
910
910
  return "style_zh_cn";
911
911
  }
912
912
  };
913
- const place2point = (place) => [place.lng, place.lat];
913
+ const place2point = (place) => [Number(place.lng), Number(place.lat)];
914
914
  const pipeAsync = (fn) => (...args) => {
915
915
  Promise.resolve().then(() => fn == null ? void 0 : fn(...args));
916
916
  };
@@ -941,6 +941,35 @@ const isPlaceEqual = (p1, p2) => {
941
941
  const isPointEqual = (p1, p2) => {
942
942
  return p1[0] === (p2 == null ? void 0 : p2[0]) && p1[1] === (p2 == null ? void 0 : p2[1]);
943
943
  };
944
+ const isGeoPositionEqual = (p1, p2) => {
945
+ if (!p2)
946
+ return false;
947
+ return p1.coords.longitude === p2.coords.longitude && p1.coords.latitude === p2.coords.latitude;
948
+ };
949
+ const toPlaceType = (maybePlace) => {
950
+ const lng = Number(maybePlace.lng);
951
+ if (isNaN(lng))
952
+ throw new Error("MyError: expect lng to be number");
953
+ const lat = Number(maybePlace.lat);
954
+ if (isNaN(lat))
955
+ throw new Error("MyError: expect lat to be number");
956
+ return { lng, lat, name: maybePlace.name };
957
+ };
958
+ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
959
+ const { longitude, latitude, accuracy } = res;
960
+ const speed = Number(res.speed);
961
+ const timestamp = Date.now();
962
+ const coords = {
963
+ accuracy: Number(accuracy),
964
+ altitude: null,
965
+ altitudeAccuracy: null,
966
+ heading: null,
967
+ latitude: Number(latitude),
968
+ longitude: Number(longitude),
969
+ speed
970
+ };
971
+ return { timestamp, coords };
972
+ };
944
973
  const deepCompareEqualsForMaps = createComparator((deepEqual) => (a, b) => {
945
974
  if (isLatLngLiteral(a) || isLatLngLiteral(b)) {
946
975
  return new google.maps.LatLng(a).equals(new google.maps.LatLng(b));
@@ -2211,12 +2240,12 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2211
2240
  "attrs": {
2212
2241
  "mapRef": setMap,
2213
2242
  "mapId": gmapId,
2214
- "center": center ? vec2lnglat(center.map(Number)) : void 0,
2243
+ "center": center ? vec2lnglat(center) : void 0,
2215
2244
  "zoom": zoom,
2216
2245
  "disableDefaultUI": true,
2217
2246
  "clickableIcons": false,
2218
2247
  "disableDoubleClickZoom": touchEnable,
2219
- "gestureHandling": touchEnable ? "auto" : "none",
2248
+ "gestureHandling": touchEnable ? "greedy" : "none",
2220
2249
  "keyboardShortcuts": touchEnable,
2221
2250
  "touchZoomCenter": touchZoomCenter
2222
2251
  },
@@ -3025,6 +3054,90 @@ const BusinessQuotingMap = defineLagecySetup(function BusinessQuotingMap2(props)
3025
3054
  })]);
3026
3055
  };
3027
3056
  }).props(["fallback", "from", "loading", "mapRef", "registerOverlay", "renderDescription", "to", "fromDescription", "log"]);
3057
+ const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3058
+ const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3059
+ const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
3060
+ const takeIsForceBrowserGeo = () => {
3061
+ const searchParam = new URLSearchParams(location.search);
3062
+ return searchParam.has(`force-browser-geo`);
3063
+ };
3064
+ const sleep$1 = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
3065
+ const wxReady = () => new Promise((resolve, reject) => {
3066
+ wx.ready(resolve);
3067
+ wx.error(reject);
3068
+ });
3069
+ const detectPlatform = () => {
3070
+ const useragent = navigator.userAgent.toLowerCase();
3071
+ if (useragent.includes("micromessenger"))
3072
+ return "wechat";
3073
+ if (useragent.includes("alipay"))
3074
+ return "alipay";
3075
+ return "other";
3076
+ };
3077
+ function wechatWatchPosition(onSuccess, onError, option) {
3078
+ const { timeout } = option;
3079
+ let enable = true;
3080
+ let interval = WX_GET_LOCATION_INTERVAL_STILL;
3081
+ let prevGeoPosition = void 0;
3082
+ const startWatch = async () => {
3083
+ await wxReady();
3084
+ do {
3085
+ const geoPosition = await new Promise((resolve, reject) => {
3086
+ let isHandled = false;
3087
+ wx.getLocation({
3088
+ type: "wgs84",
3089
+ success(res) {
3090
+ if (isHandled)
3091
+ return;
3092
+ isHandled = true;
3093
+ const speed = Number(res.speed);
3094
+ interval = speed === 0 ? WX_GET_LOCATION_INTERVAL_STILL : speed < 2 ? WX_GET_LOCATION_INTERVAL_SLOW : WX_GET_LOCATION_INTERVAL_FAST;
3095
+ resolve(wxGetLocationSuccessResponse2GeolocationPosition(res));
3096
+ },
3097
+ fail(res) {
3098
+ if (isHandled)
3099
+ return;
3100
+ isHandled = true;
3101
+ const error = new Error(res.errMsg);
3102
+ reject(error);
3103
+ onError == null ? void 0 : onError(error);
3104
+ }
3105
+ });
3106
+ if (!timeout)
3107
+ return;
3108
+ setTimeout(() => {
3109
+ if (isHandled)
3110
+ return;
3111
+ interval = WX_GET_LOCATION_INTERVAL_SLOW;
3112
+ resolve(void 0);
3113
+ }, timeout);
3114
+ });
3115
+ if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
3116
+ onSuccess(geoPosition);
3117
+ prevGeoPosition = geoPosition;
3118
+ await sleep$1(interval);
3119
+ } while (enable);
3120
+ };
3121
+ startWatch();
3122
+ return () => {
3123
+ enable = false;
3124
+ };
3125
+ }
3126
+ function compatibleWathPosition(onSuccess, onError, option) {
3127
+ const isForceBrowserGeo = takeIsForceBrowserGeo();
3128
+ if (isForceBrowserGeo) {
3129
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3130
+ return () => navigator.geolocation.clearWatch(watchId);
3131
+ }
3132
+ switch (detectPlatform()) {
3133
+ case "wechat":
3134
+ return wechatWatchPosition(onSuccess, onError, option);
3135
+ default: {
3136
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3137
+ return () => navigator.geolocation.clearWatch(watchId);
3138
+ }
3139
+ }
3140
+ }
3028
3141
  const isPlace = (place) => {
3029
3142
  return place.lng !== void 0 && place.lat !== void 0;
3030
3143
  };
@@ -3044,7 +3157,7 @@ class SingleGeoWatch {
3044
3157
  __publicField(this, "id", 0);
3045
3158
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
3046
3159
  __publicField(this, "option", {});
3047
- __publicField(this, "singleWatchId");
3160
+ __publicField(this, "unwatch");
3048
3161
  this.option = option != null ? option : {};
3049
3162
  }
3050
3163
  watchPosition(onSuccess, onError) {
@@ -3058,12 +3171,12 @@ class SingleGeoWatch {
3058
3171
  this.listeners.delete(id);
3059
3172
  }
3060
3173
  async start() {
3061
- const { listeners, option, singleWatchId } = this;
3062
- if (singleWatchId) {
3063
- navigator.geolocation.clearWatch(singleWatchId);
3174
+ const { listeners, option, unwatch } = this;
3175
+ if (unwatch) {
3176
+ unwatch();
3064
3177
  await sleep(20);
3065
3178
  }
3066
- this.singleWatchId = navigator.geolocation.watchPosition(
3179
+ this.unwatch = compatibleWathPosition(
3067
3180
  (position) => {
3068
3181
  for (const [onSuccess] of listeners.values()) {
3069
3182
  onSuccess(position);
@@ -3134,10 +3247,12 @@ const useGeoLocation = (props) => {
3134
3247
  watch(
3135
3248
  () => true,
3136
3249
  (_1, _2, onCleanup) => {
3250
+ const logStartTime = Date.now();
3137
3251
  loading.value = true;
3138
3252
  const watchId = singleGeoWatch.watchPosition(
3139
3253
  async (position) => {
3140
- console.log("watchPosition success position = ", position);
3254
+ const duration = Date.now() - logStartTime;
3255
+ spaceLog("watchPosition", "success duration, position = ", duration, position);
3141
3256
  const coordinate = position.coords;
3142
3257
  const wgsPoint = [position.coords.longitude, position.coords.latitude];
3143
3258
  const point = await toGcj02(wgsPoint);
@@ -3151,7 +3266,7 @@ const useGeoLocation = (props) => {
3151
3266
  onChange == null ? void 0 : onChange({ position: point, coordinate });
3152
3267
  },
3153
3268
  (error) => {
3154
- console.log("watchPosition error = ", error);
3269
+ spaceLog("watchPosition", "error.message = ", error.message);
3155
3270
  loading.value = false;
3156
3271
  errorRef.value = error;
3157
3272
  const position = props == null ? void 0 : props.geoDefaultPosition;
@@ -3946,8 +4061,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3946
4061
  centerSource.source = "api";
3947
4062
  updatePlace(point);
3948
4063
  };
3949
- const setCenterPlaceByUserSpecified = async (place) => {
4064
+ const setCenterPlaceByUserSpecified = async (input) => {
3950
4065
  centerSource.source = "api";
4066
+ const place = toPlaceType(input);
3951
4067
  centerPlace.lng = place.lng;
3952
4068
  centerPlace.lat = place.lat;
3953
4069
  centerPlace.name = place.name;
@@ -3973,14 +4089,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3973
4089
  } = useGeoLocation({
3974
4090
  geoDefaultPosition,
3975
4091
  onLoad: async (value) => {
3976
- console.log("useGeoLocation onLoad value = ", value);
3977
4092
  await readyPromise;
3978
4093
  centerSource.source = "geo";
3979
4094
  updatePlace(value.position);
3980
4095
  emit("loadGeoLocation", value);
3981
4096
  },
3982
4097
  onLoadDefault: async (value) => {
3983
- console.log("useGeoLocation onLoadDefault value = ", value);
3984
4098
  await readyPromise;
3985
4099
  const place = await defaultCenterPlacePromise;
3986
4100
  centerSource.source = "geo";
@@ -4074,7 +4188,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
4074
4188
  } = props;
4075
4189
  const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
4076
4190
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
4077
- console.log("BusinessRecomendPlaceMap render geoLoading, isFirstWorkflowRecomendLoadingRef = ", geoLoading.value, isFirstWorkflowRecomendLoadingRef.value);
4078
4191
  return h(HeycarMap, {
4079
4192
  "attrs": {
4080
4193
  "center": centerPoint.value,
@@ -5009,10 +5122,12 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
5009
5122
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
5010
5123
  return () => {
5011
5124
  const {
5012
- from,
5013
- to
5125
+ from: inputFrom,
5126
+ to: inputTo
5014
5127
  } = props;
5015
- const isReady = isPlace(from) && isPlace(to);
5128
+ const isReady = isPlace(inputFrom) && isPlace(inputTo);
5129
+ const from = toPlaceType(inputFrom);
5130
+ const to = toPlaceType(inputTo);
5016
5131
  const center = isReady ? place2point(from) : [...BEIJIN_POINT];
5017
5132
  return h(HeycarMap, {
5018
5133
  "attrs": {
@@ -5076,12 +5191,14 @@ const BusinessTaxiServiceMap = defineLagecySetup(function BusinessTaxiServiceMap
5076
5191
  return () => {
5077
5192
  const {
5078
5193
  driverStatus,
5079
- from,
5080
- to,
5194
+ from: inputFrom,
5195
+ to: inputTo,
5081
5196
  dispatchingTitle,
5082
5197
  bookDispatchingTitle,
5083
5198
  driverArrivedTitle
5084
5199
  } = props;
5200
+ const from = toPlaceType(inputFrom);
5201
+ const to = toPlaceType(inputTo);
5085
5202
  const carPosition = carPositionRef.value;
5086
5203
  const carAngle = carAngleRef.value;
5087
5204
  const touchEnable = !["canceled", "canceling", "completed", "endService", "waitpay", "waitRechargePay", "refund", "rechargePayed", "payed"].includes(driverStatus);
package/dist/style.css CHANGED
@@ -126,6 +126,10 @@ a[title*="Google"]>div>img[alt="Google"], .gmnoprint {
126
126
  }
127
127
  ._7anfuo0 [class*="marker-view"] {
128
128
  will-change: unset !important;
129
+ }
130
+ ._7anfuo0 a, ._7anfuo0 img, ._7anfuo0 div, ._7anfuo0 button {
131
+ -webkit-tap-highlight-color: transparent;
132
+ outline: none;
129
133
  }._4a4ovk0 {
130
134
  margin-bottom: -0.4vw;
131
135
  display: flex;
@@ -0,0 +1,21 @@
1
+ export interface WxResponse {
2
+ errMsg: string;
3
+ }
4
+ export interface WxGetLocationSuccessResponse extends WxResponse {
5
+ latitude: string;
6
+ longitude: string;
7
+ speed: string;
8
+ accuracy: string;
9
+ }
10
+ interface WxGetLocationProps {
11
+ type: "wgs84" | "gcj02";
12
+ success: (response: WxGetLocationSuccessResponse) => void;
13
+ fail?: (response: WxResponse) => void;
14
+ complete?: (response: WxResponse) => void;
15
+ }
16
+ export interface Wx {
17
+ ready: (callback: () => void) => void;
18
+ error: (callback: (response: WxResponse) => void) => void;
19
+ getLocation: (props: WxGetLocationProps) => void;
20
+ }
21
+ export {};
@@ -1,3 +1,4 @@
1
+ import { type ClearWathPosition } from "./compatibleWatchPosition";
1
2
  /**
2
3
  * @note navigator.geolocation.watchPosition 期间,再调用 watchPosition 或 getCurrentPosition 会导致定位失败。
3
4
  */
@@ -5,7 +6,7 @@ export declare class SingleGeoWatch {
5
6
  id: number;
6
7
  listeners: Map<number, [PositionCallback, PositionErrorCallback | undefined]>;
7
8
  option: PositionOptions;
8
- singleWatchId: number | undefined;
9
+ unwatch: ClearWathPosition | undefined;
9
10
  constructor(option?: PositionOptions);
10
11
  watchPosition(onSuccess: PositionCallback, onError?: PositionErrorCallback): number;
11
12
  clearWatch(id: number): void;
@@ -0,0 +1,2 @@
1
+ export type ClearWathPosition = () => void;
2
+ export declare function compatibleWathPosition(onSuccess: PositionCallback, onError: PositionErrorCallback, option: PositionOptions): ClearWathPosition;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="google.maps" />
2
2
  import type { Place, Point } from "../types/interface";
3
+ import type { WxGetLocationSuccessResponse } from "../types/wx";
3
4
  export declare const vec2lnglat: ([lng, lat]: [number, number]) => google.maps.LatLngLiteral;
4
5
  export interface AsteriskItem {
5
6
  type: "normal" | "emphasize";
@@ -16,3 +17,10 @@ export declare const pipeDefer: <P extends any[], R>(fn: (...args: P) => R) => (
16
17
  export declare const pipeOnlyLastEffect: <P extends any[], R>(fn: (...arg: P) => Promise<R>) => (...args: P) => Promise<R>;
17
18
  export declare const isPlaceEqual: (p1: Place, p2?: Place) => boolean;
18
19
  export declare const isPointEqual: (p1: Point, p2?: Point) => boolean;
20
+ export declare const isGeoPositionEqual: (p1: GeolocationPosition, p2?: GeolocationPosition) => boolean;
21
+ export declare const toPlaceType: (maybePlace: {
22
+ name: string;
23
+ lng: string | number;
24
+ lat: string | number;
25
+ }) => Place;
26
+ export declare const wxGetLocationSuccessResponse2GeolocationPosition: (res: WxGetLocationSuccessResponse) => GeolocationPosition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -120,3 +120,12 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
120
120
  - 5546
121
121
  - 5541
122
122
  - 5540
123
+
124
+ 0.6.5
125
+
126
+ - 5640
127
+ - 5631
128
+ - 5614
129
+ - 5598
130
+ - 5567
131
+ - 5560