@heycar/heycars-map 0.1.9 → 0.2.0
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/README.md +30 -7
- package/dist/business-components/StartEndPoint/StartEndPoint.d.ts +18309 -4
- package/dist/components/AmapLoader/AmapLoader.d.ts +5 -20
- package/dist/components/AmapMarker/AmapMarker.d.ts +3 -2
- package/dist/components/Demo/HeycarDemo.d.ts +3 -3
- package/dist/components/Demo/searchResult.d.ts +1 -1
- package/dist/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.d.ts +3 -2
- package/dist/components/GmapLoader/GmapLoader.d.ts +3 -35
- package/dist/components/GmapMarker/GmapMarker.d.ts +3 -2
- package/dist/components/MapProvider/MapProvider.d.ts +4 -5
- package/dist/hooks/useGeoLocation.d.ts +2 -2
- package/dist/hooks/useMap.d.ts +801 -0
- package/dist/hooks/useMapAutoComplete.d.ts +4 -6
- package/dist/hooks/useMapCityBound.d.ts +5 -6
- package/dist/hooks/useMapEventSource.d.ts +5 -0
- package/dist/hooks/useMapFitView.d.ts +4599 -0
- package/dist/hooks/useMapLoader.d.ts +67 -0
- package/dist/hooks/useMapPlace.d.ts +4 -6
- package/dist/hooks/useMapRecomendPlace.d.ts +5 -797
- package/dist/hooks/useMapSupplier.d.ts +8 -0
- package/dist/hooks/useOverlay.d.ts +12 -0
- package/dist/hooks-business/useBusinessMapAutoComplete.d.ts +5 -5
- package/dist/hooks-business/useBusinessMapRecomendPlace.d.ts +4 -3
- package/dist/index.cjs +52 -52
- package/dist/index.js +1153 -1116
- package/dist/types/interface.d.ts +4 -0
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- package/src/api/place.ts +0 -2
- package/src/business-components/AddressBox/AddressBox.tsx +1 -1
- package/src/business-components/AddressLocator/AddressLocator.tsx +1 -1
- package/src/business-components/DrivingLine/DrivingLine.tsx +1 -1
- package/src/business-components/DrivingRoute/DrivingRoute.tsx +2 -3
- package/src/business-components/PassengerCircle/PassengerCircle.tsx +1 -1
- package/src/business-components/PlaceCircle/PlaceCircle.tsx +1 -1
- package/src/business-components/StartEndPoint/StartEndPoint.tsx +23 -7
- package/src/business-components/TaxiCar/TaxiCar.tsx +1 -1
- package/src/business-components/WalkingLine/WalkingLine.tsx +1 -1
- package/src/business-components/WalkingRoute/WalkingRoute.tsx +2 -3
- package/src/business-components/WaveCircle/WaveCircle.tsx +1 -1
- package/src/components/Amap/Amap.ts +1 -1
- package/src/components/AmapInfoWindow/AmapInfoWindow.ts +1 -1
- package/src/components/AmapLoader/AmapLoader.ts +6 -54
- package/src/components/AmapMarker/AmapMarker.ts +5 -2
- package/src/components/AmapPolygon/AmapPolygon.ts +1 -1
- package/src/components/AmapPolyline/AmapPolyline.ts +1 -1
- package/src/components/AmapText/AmapText.ts +1 -1
- package/src/components/Demo/Demo.css.ts +1 -1
- package/src/components/Demo/HeycarDemo.tsx +50 -33
- package/src/components/Demo/SearchDemo.tsx +40 -65
- package/src/components/Demo/searchResult.ts +12888 -1
- package/src/components/Gmap/Gmap.ts +17 -5
- package/src/components/GmapAdvancedMarkerView/GmapAdvancedMarkerView.ts +9 -4
- package/src/components/GmapInfoWindow/GmapInfoWindow.ts +1 -1
- package/src/components/GmapLoader/GmapLoader.ts +4 -62
- package/src/components/GmapMarker/GmapMarker.ts +5 -2
- package/src/components/GmapPolygon/GmapPolygon.ts +1 -1
- package/src/components/GmapPolyline/GmapPolyline.ts +1 -1
- package/src/components/MapProvider/MapProvider.tsx +33 -50
- package/src/hooks/useDrivingRoute.ts +1 -1
- package/src/hooks/useGeoLocation.ts +4 -2
- package/src/hooks/useHeycarMap.ts +1 -1
- package/src/hooks/useMap.ts +29 -0
- package/src/hooks/useMapAngle.ts +1 -1
- package/src/hooks/useMapAutoComplete.ts +16 -19
- package/src/hooks/useMapCityBound.ts +36 -24
- package/src/hooks/useMapDrag.ts +1 -1
- package/src/hooks/useMapEventSource.ts +20 -0
- package/src/hooks/useMapFitView.ts +127 -0
- package/src/hooks/useMapLoader.ts +164 -0
- package/src/hooks/useMapPlace.ts +20 -22
- package/src/hooks/useMapRecomendPlace.ts +18 -25
- package/src/{components/MapProvider → hooks}/useMapSupplier.ts +4 -7
- package/src/hooks/useOverlay.ts +22 -0
- package/src/hooks/useWalkingRoute.ts +1 -1
- package/src/hooks-business/useBusinessMapAutoComplete.ts +13 -7
- package/src/hooks-business/useBusinessMapRecomendPlace.ts +10 -10
- package/src/types/interface.ts +5 -0
- package/dist/components/Amap/useAmap.d.ts +0 -399
- package/dist/components/Gmap/useGmap.d.ts +0 -5
- package/dist/components/MapProvider/useMapSupplier.d.ts +0 -11
- package/dist/hooks/useMapReady.d.ts +0 -4
- package/src/components/Amap/useAmap.ts +0 -9
- package/src/components/Gmap/useGmap.ts +0 -7
- package/src/hooks/useMapReady.ts +0 -14
|
@@ -34,72 +34,47 @@ const SomePage = defineSetup(function Hello() {
|
|
|
34
34
|
const searchName = async (idx: number, address: string, country: string) => {
|
|
35
35
|
const geocoder = new google.maps.Geocoder();
|
|
36
36
|
// const placeService = new google.maps.places.PlacesService(document.createElement("div"));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
geocoder.geocode(
|
|
39
|
+
{
|
|
40
|
+
address,
|
|
41
|
+
componentRestrictions: {
|
|
42
|
+
country,
|
|
43
|
+
administrativeArea: "administrative_area_level_1",
|
|
44
|
+
},
|
|
45
|
+
language: "en",
|
|
46
|
+
},
|
|
47
|
+
(results, status) => {
|
|
48
|
+
switch (status) {
|
|
49
|
+
case google.maps.GeocoderStatus.OK: {
|
|
50
|
+
if (results?.length === 2) {
|
|
51
|
+
const [result1, result2] = results;
|
|
52
|
+
const isResult1Admin = result1.types[0].startsWith("administrative_area_level_");
|
|
53
|
+
const isResult2Admin = result2.types[0].startsWith("administrative_area_level_");
|
|
54
|
+
if (isResult1Admin && !isResult2Admin) {
|
|
55
|
+
return resolve(result1.geometry.bounds?.toJSON());
|
|
56
|
+
}
|
|
57
|
+
if (isResult2Admin && !isResult1Admin) {
|
|
58
|
+
return resolve(result2.geometry.bounds?.toJSON());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (results?.length !== 1) {
|
|
62
|
+
console.warn("length !== 1 by idx, keyword, results = ", idx, address, results);
|
|
63
|
+
return resolve(undefined);
|
|
64
|
+
}
|
|
65
|
+
const { geometry } = results[0];
|
|
66
|
+
const output = geometry.bounds?.toJSON() ?? geometry.viewport.toJSON();
|
|
67
|
+
return resolve(output);
|
|
68
|
+
}
|
|
69
|
+
case google.maps.GeocoderStatus.ZERO_RESULTS: {
|
|
70
|
+
return resolve(undefined);
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
throw reject(status);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
44
77
|
});
|
|
45
|
-
if (results?.length === 2) {
|
|
46
|
-
const [result1, result2] = results;
|
|
47
|
-
const isResult1Admin = result1.types[0].startsWith("administrative_area_level_");
|
|
48
|
-
const isResult2Admin = result2.types[0].startsWith("administrative_area_level_");
|
|
49
|
-
if (isResult1Admin && !isResult2Admin) {
|
|
50
|
-
return result1.geometry.bounds?.toJSON();
|
|
51
|
-
}
|
|
52
|
-
if (isResult2Admin && !isResult1Admin) {
|
|
53
|
-
return result2.geometry.bounds?.toJSON();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (results?.length !== 1) {
|
|
57
|
-
console.warn("length !== 1 by idx, keyword, results = ", idx, address, results);
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
const { geometry } = results[0];
|
|
61
|
-
return geometry.bounds?.toJSON() ?? geometry.viewport.toJSON();
|
|
62
|
-
|
|
63
|
-
// const autocompleteService = new google.maps.places.AutocompleteService();
|
|
64
|
-
// const placeService = new google.maps.places.PlacesService(map);
|
|
65
|
-
// const { predictions } = await autocompleteService.getPlacePredictions({
|
|
66
|
-
// input: "麦当劳",
|
|
67
|
-
// language: "zh",
|
|
68
|
-
// componentRestrictions: {
|
|
69
|
-
// country: "CN",
|
|
70
|
-
// },
|
|
71
|
-
// bounds: {
|
|
72
|
-
// // north: 122.3172401,
|
|
73
|
-
// // east: 31.8675299,
|
|
74
|
-
// // south: 120.8559198,
|
|
75
|
-
// // west: 30.6703899,
|
|
76
|
-
// north: 31.8675299,
|
|
77
|
-
// east: 122.3172401,
|
|
78
|
-
// south: 30.6703899,
|
|
79
|
-
// west: 120.8559198,
|
|
80
|
-
// },
|
|
81
|
-
// });
|
|
82
|
-
// console.log("predictions = ", predictions);
|
|
83
|
-
// if (results.length !== 1) {
|
|
84
|
-
// console.log("results = ", results);
|
|
85
|
-
// throw new Error("MyError, results.length !== 1");
|
|
86
|
-
// }
|
|
87
|
-
// const placeId = results[0].place_id;
|
|
88
|
-
// const { results: accurateResults } = await geocoder.geocode({ placeId });
|
|
89
|
-
// if (accurateResults.length !== 1) {
|
|
90
|
-
// console.log("results = ", accurateResults);
|
|
91
|
-
// throw new Error("MyError, accurateResults.length !== 1");
|
|
92
|
-
// }
|
|
93
|
-
// const detail = accurateResults[0];
|
|
94
|
-
// console.log("detail = ", detail);
|
|
95
|
-
|
|
96
|
-
// placeService.getDetails({ placeId }, (result, status) => {
|
|
97
|
-
// if (status !== google.maps.places.PlacesServiceStatus.OK) {
|
|
98
|
-
// console.log("result, status = ", result, status);
|
|
99
|
-
// throw new Error("My Error getDetails status !== ok");
|
|
100
|
-
// }
|
|
101
|
-
// console.log("detail = ", result);
|
|
102
|
-
// });
|
|
103
78
|
};
|
|
104
79
|
const wait = (seconds: number) => new Promise((r) => setTimeout(r, seconds * 1000));
|
|
105
80
|
const search = async (from: number, to: number) => {
|