@heycar/heycars-map 0.2.11 → 0.2.12

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": "@heycar/heycars-map",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
@@ -91,4 +91,4 @@
91
91
  "engines": {
92
92
  "node": ">=16.0.0"
93
93
  }
94
- }
94
+ }
package/src/App.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineComponent } from "vue-demi";
2
2
  import { MapProvider } from "./components/MapProvider";
3
- import { DemoBusinessTaxiService } from "./Demo/DemoBusinessTaxiService";
3
+ import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace";
4
4
 
5
5
  const gmapApiKey = import.meta.env.VITE_GMAP_API_KEY;
6
6
  const gmapId = import.meta.env.VITE_GMAP_MAP_ID;
@@ -17,9 +17,9 @@ export const App = defineComponent({
17
17
  gmapKey={gmapApiKey}
18
18
  supplier={"amap"}
19
19
  >
20
- {/* <DemoBusinessRecomendPlace /> */}
20
+ <DemoBusinessRecomendPlace />
21
21
  {/* <DemoBusinessQuoting /> */}
22
- <DemoBusinessTaxiService />
22
+ {/* <DemoBusinessTaxiService /> */}
23
23
  {/* <DemoBusinessTaxiEnd /> */}
24
24
  </MapProvider>
25
25
  );
@@ -37,41 +37,21 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
37
37
  ) => {
38
38
  const { lat, lng } = place;
39
39
  console.log("getRecomendPlace context?.source = ", context?.source);
40
- return [
41
- {
42
- address: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
43
- distance: 68,
44
- lat: 1.2961134,
45
- lng: 103.7722912,
46
- name: "2 College Ave West, Stephen Riady Centre, Singapore 138607",
47
- reqFrom: "Recent",
48
- },
49
- {
50
- address: "10 Architecture Drive, Singapore",
51
- distance: 71,
52
- lat: 1.2969847,
53
- lng: 103.7714507,
54
- name: "Centre for English Language Communication (CELC)",
55
- reqFrom: "public",
56
- },
57
- {
58
- address: "10 Kent Ridge Crescent, #01-02 Block AS8",
59
- distance: 75,
60
- lat: 1.295979,
61
- lng: 103.7720608,
62
- name: "The Coffee Roaster Cafe @ NUS",
63
- reqFrom: "public",
64
- },
65
- ];
66
-
67
40
  return [
68
41
  { lat: lat + 0.0001, lng: lng + 0.0001, name: "place name 1" },
69
42
  { lat: lat + 0.002, lng: lng + 0.002, name: "place name 2" },
70
43
  ];
71
44
  };
72
- const { centerPlace, placeCandidates, setCenterPlaceByRecomand, mapContext, apiMapDistance } =
73
- useBusinessRecomendPlaceMap();
45
+ const {
46
+ centerPlace,
47
+ placeCandidates,
48
+ setCenterPlaceByRecomand,
49
+ mapContext,
50
+ apiMapDistance,
51
+ panToGeoPositionByRecomend,
52
+ } = useBusinessRecomendPlaceMap();
74
53
  (window as any).setCenterPlaceByRecomand = setCenterPlaceByRecomand;
54
+ (window as any).panToGeoPositionByRecomend = panToGeoPositionByRecomend;
75
55
  return () => {
76
56
  return (
77
57
  <div>
@@ -80,7 +60,6 @@ export const DemoBusinessRecomendPlace = defineSetup(function DemoBusinessRecome
80
60
  {centerPlace.cityName} | {centerPlace.countryName} <br />
81
61
  <SomeAutoComplete cityName="Taiwan"></SomeAutoComplete>
82
62
  <BusinessRecomendPlaceMap
83
- log
84
63
  class={css.demo}
85
64
  unavailableTitle={"当前区域暂未开通服务"}
86
65
  noRecomendDescription={"附近无推荐上车地点"}
@@ -56,8 +56,6 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
56
56
  centerPlace.lat = point[1];
57
57
  updatePlace();
58
58
  };
59
- mapContext.setCenterPlaceByRecomand = setCenterPlaceByRecomand;
60
- mapContext.panTo = panTo;
61
59
  const setCenterByPlace = (place: Place) => {
62
60
  centerSource.source = "api";
63
61
  centerPlace.lng = place.lng;
@@ -65,7 +63,7 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
65
63
  centerPlace.name = place.name;
66
64
  };
67
65
 
68
- const { geoPosition } = useGeoLocation({
66
+ const { geoPosition, geoError } = useGeoLocation({
69
67
  geoDefaultPosition,
70
68
  onLoad: async (value) => {
71
69
  // geo 主入口
@@ -88,6 +86,12 @@ export const BusinessRecomendPlaceMap = defineLagecySetup(
88
86
  onChange: (v) => emit("changeGeoLocation", v),
89
87
  onError: (e) => emit("geoError", e),
90
88
  });
89
+ mapContext.setCenterPlaceByRecomand = setCenterPlaceByRecomand;
90
+ mapContext.panToGeoPositionByRecomend = () => {
91
+ if (geoError.value) return false;
92
+ setCenterPlaceByRecomand(geoPosition.value);
93
+ return true;
94
+ };
91
95
  const { isDragging } = useMapDrag({
92
96
  mapRef,
93
97
  onChange: (point) => {
@@ -3,7 +3,7 @@ import { useMapGeometry } from "../hooks/useMapGeometry";
3
3
  import type { Place, Point } from "../types/interface";
4
4
 
5
5
  export interface BusinessRecomendPlaceContext {
6
- panTo: (value: Point) => void;
6
+ panToGeoPositionByRecomend: (value: Point) => void;
7
7
  setCenterPlaceByRecomand: (value: Point) => void;
8
8
  onChangeCenterPlace: (value: Place) => void;
9
9
  onChangeRecomendPlaces: (value: Place[]) => void;
@@ -18,11 +18,11 @@ export const useBusinessRecomendPlaceMap = () => {
18
18
  });
19
19
  const placeCandidates = ref<Place[]>([]);
20
20
  const { apiMapDistance } = useMapGeometry();
21
- const panTo = (value: Point) => mapContext.panTo(value);
21
+ const panToGeoPositionByRecomend = (value: Point) => mapContext.panToGeoPositionByRecomend(value);
22
22
  const setCenterPlaceByRecomand = (value: Point) => mapContext.setCenterPlaceByRecomand(value);
23
23
  const mapContext: BusinessRecomendPlaceContext = {
24
- panTo: () => {
25
- throw new Error("MyError: panTo used before assigned");
24
+ panToGeoPositionByRecomend: () => {
25
+ throw new Error("MyError: panToGeoPositionByRecomend used before assigned");
26
26
  },
27
27
  setCenterPlaceByRecomand: () => {
28
28
  throw new Error("MyError: setCenterPlaceByRecomand used before assigned");
@@ -38,7 +38,7 @@ export const useBusinessRecomendPlaceMap = () => {
38
38
  mapContext,
39
39
  centerPlace,
40
40
  placeCandidates,
41
- panTo,
41
+ panToGeoPositionByRecomend,
42
42
  setCenterPlaceByRecomand,
43
43
  apiMapDistance,
44
44
  };
package/todo.md CHANGED
@@ -26,6 +26,4 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
26
26
 
27
27
  ---
28
28
 
29
- 1. apiDistance 在 created 生命周期里调用的时候,即便设置了 5 秒延迟,运行到 api 内部的时候 status === 'loading'
30
- 2. getRecomend 接口需要增加一个返回参数,表示当前地区是否可以提供服务
31
- 3. 孙明 刚才传入 complted 状态,地图未显示
29
+ 1. 定位失败的视觉稿文字提示