@heycar/heycars-map 0.11.0-google1 → 0.11.0-google3
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/v2/hooks/useMapPlace.js +4 -3
- package/dist/v2/types/gmap.d.ts +1 -1
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.js +9 -7
- package/dist/v3/hooks/useMapPlace.js +4 -3
- package/dist/v3/types/gmap.d.ts +1 -1
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.js +9 -7
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { ref, reactive, watch } from "vue-demi";
|
|
|
2
2
|
import { REGEO_TIMEOUT } from "../api/contants.js";
|
|
3
3
|
import { createPipeTw } from "../utils/cn2tw.js";
|
|
4
4
|
import { equalAssign } from "../utils/helper.js";
|
|
5
|
-
import { amapPlaceName2DisplayName } from "../utils/transform.js";
|
|
5
|
+
import { amapPlaceName2DisplayName, gmapPlaceName2DisplayName } from "../utils/transform.js";
|
|
6
6
|
import { useAmapInChina } from "./useMapInChina.js";
|
|
7
7
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
8
8
|
import { useUpdate } from "./useUdate.js";
|
|
@@ -99,9 +99,10 @@ const useGmapPlace = (props) => {
|
|
|
99
99
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
100
100
|
geocoder.geocode({ language, location: { lng, lat } }).then(({ results }) => {
|
|
101
101
|
const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
|
|
102
|
-
const displayName = name;
|
|
102
|
+
const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
|
|
103
103
|
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
104
|
-
}).catch(() => {
|
|
104
|
+
}).catch((err) => {
|
|
105
|
+
console.error(err);
|
|
105
106
|
const name = emptyPlaceName;
|
|
106
107
|
const displayName = emptyPlaceName;
|
|
107
108
|
resolve({ lng, lat, name, displayName });
|
package/dist/v2/types/gmap.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type GmapGeocoderAddressComponentType = "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
|
|
1
|
+
export type GmapGeocoderAddressComponentType = "street_number" | "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "0.11.0-
|
|
3
|
+
const pkgVersion = "0.11.0-google3";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -130,15 +130,17 @@ function amapPlaceName2DisplayNameOutChina(name, options) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
const GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX = /(?:^\s*,?\s*|\s*,?\s*$)/g;
|
|
133
|
+
const EMPTY_REGEX = /^$/;
|
|
134
|
+
const POSTAL_CODE_ZH_DESC = "邮政编码:";
|
|
133
135
|
function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
134
136
|
var _a, _b;
|
|
135
137
|
const addressComponentMap = gmapAddressComponentList2AddressComponentMap(addressComponents);
|
|
136
|
-
const
|
|
138
|
+
const streetNumberComponent = addressComponentMap["street_number"];
|
|
137
139
|
const routeComponent = addressComponentMap["route"];
|
|
138
|
-
const
|
|
139
|
-
const routeName = routeComponent.long_name ? routeComponent.long_name : routeComponent.short_name;
|
|
140
|
-
if (
|
|
141
|
-
return `${
|
|
140
|
+
const streetNumberName = (streetNumberComponent == null ? void 0 : streetNumberComponent.long_name) ? streetNumberComponent.long_name : streetNumberComponent == null ? void 0 : streetNumberComponent.short_name;
|
|
141
|
+
const routeName = (routeComponent == null ? void 0 : routeComponent.long_name) ? routeComponent.long_name : routeComponent == null ? void 0 : routeComponent.short_name;
|
|
142
|
+
if (streetNumberName && routeName)
|
|
143
|
+
return `${streetNumberName} ${routeName}`;
|
|
142
144
|
const unnecessaryTypes = [
|
|
143
145
|
"postal_code",
|
|
144
146
|
"country",
|
|
@@ -152,7 +154,7 @@ function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
|
152
154
|
const { long_name: long_name2, short_name: short_name2 } = (_a = addressComponentMap[type]) != null ? _a : {};
|
|
153
155
|
if (!long_name2 && !short_name2)
|
|
154
156
|
continue;
|
|
155
|
-
const replacedName2 = result.replace(long_name2, "").replace(short_name2, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
157
|
+
const replacedName2 = result.replace(long_name2 != null ? long_name2 : EMPTY_REGEX, "").replace(short_name2 != null ? short_name2 : EMPTY_REGEX, "").replace(POSTAL_CODE_ZH_DESC, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
156
158
|
if (!replacedName2)
|
|
157
159
|
return result;
|
|
158
160
|
result = replacedName2;
|
|
@@ -162,7 +164,7 @@ function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
|
162
164
|
const { long_name, short_name } = (_b = addressComponentMap["locality"]) != null ? _b : {};
|
|
163
165
|
if (!long_name && !short_name)
|
|
164
166
|
return result;
|
|
165
|
-
const replacedName = result.replace(long_name, "").replace(short_name, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
167
|
+
const replacedName = result.replace(long_name != null ? long_name : EMPTY_REGEX, "").replace(short_name != null ? short_name : EMPTY_REGEX, "").replace(POSTAL_CODE_ZH_DESC, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
166
168
|
return replacedName ? replacedName : result;
|
|
167
169
|
}
|
|
168
170
|
function gmapAddressComponentList2AddressComponentMap(addressComponents) {
|
|
@@ -2,7 +2,7 @@ import { ref, reactive, watch } from "vue-demi";
|
|
|
2
2
|
import { REGEO_TIMEOUT } from "../api/contants.js";
|
|
3
3
|
import { createPipeTw } from "../utils/cn2tw.js";
|
|
4
4
|
import { equalAssign } from "../utils/helper.js";
|
|
5
|
-
import { amapPlaceName2DisplayName } from "../utils/transform.js";
|
|
5
|
+
import { amapPlaceName2DisplayName, gmapPlaceName2DisplayName } from "../utils/transform.js";
|
|
6
6
|
import { useAmapInChina } from "./useMapInChina.js";
|
|
7
7
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
8
8
|
import { useUpdate } from "./useUdate.js";
|
|
@@ -99,9 +99,10 @@ const useGmapPlace = (props) => {
|
|
|
99
99
|
const pipeTw = createPipeTw(language === "zh-TW");
|
|
100
100
|
geocoder.geocode({ language, location: { lng, lat } }).then(({ results }) => {
|
|
101
101
|
const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
|
|
102
|
-
const displayName = name;
|
|
102
|
+
const displayName = gmapPlaceName2DisplayName(name, results[0].address_components);
|
|
103
103
|
resolve({ lng, lat, name: pipeTw(name), displayName: pipeTw(displayName) });
|
|
104
|
-
}).catch(() => {
|
|
104
|
+
}).catch((err) => {
|
|
105
|
+
console.error(err);
|
|
105
106
|
const name = emptyPlaceName;
|
|
106
107
|
const displayName = emptyPlaceName;
|
|
107
108
|
resolve({ lng, lat, name, displayName });
|
package/dist/v3/types/gmap.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type GmapGeocoderAddressComponentType = "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
|
|
1
|
+
export type GmapGeocoderAddressComponentType = "street_number" | "street_address" | "route" | "intersection" | "political" | "country" | "administrative_area_level_1" | "administrative_area_level_2" | "administrative_area_level_3" | "administrative_area_level_4" | "administrative_area_level_5" | "administrative_area_level_6" | "administrative_area_level_7" | "colloquial_area" | "locality" | "sublocality" | "neighborhood" | "premise" | "subpremise" | "plus_code" | "postal_code" | "natural_feature" | "airport" | "park" | "point_of_interest";
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "0.11.0-
|
|
3
|
+
const pkgVersion = "0.11.0-google3";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -130,15 +130,17 @@ function amapPlaceName2DisplayNameOutChina(name, options) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
const GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX = /(?:^\s*,?\s*|\s*,?\s*$)/g;
|
|
133
|
+
const EMPTY_REGEX = /^$/;
|
|
134
|
+
const POSTAL_CODE_ZH_DESC = "邮政编码:";
|
|
133
135
|
function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
134
136
|
var _a, _b;
|
|
135
137
|
const addressComponentMap = gmapAddressComponentList2AddressComponentMap(addressComponents);
|
|
136
|
-
const
|
|
138
|
+
const streetNumberComponent = addressComponentMap["street_number"];
|
|
137
139
|
const routeComponent = addressComponentMap["route"];
|
|
138
|
-
const
|
|
139
|
-
const routeName = routeComponent.long_name ? routeComponent.long_name : routeComponent.short_name;
|
|
140
|
-
if (
|
|
141
|
-
return `${
|
|
140
|
+
const streetNumberName = (streetNumberComponent == null ? void 0 : streetNumberComponent.long_name) ? streetNumberComponent.long_name : streetNumberComponent == null ? void 0 : streetNumberComponent.short_name;
|
|
141
|
+
const routeName = (routeComponent == null ? void 0 : routeComponent.long_name) ? routeComponent.long_name : routeComponent == null ? void 0 : routeComponent.short_name;
|
|
142
|
+
if (streetNumberName && routeName)
|
|
143
|
+
return `${streetNumberName} ${routeName}`;
|
|
142
144
|
const unnecessaryTypes = [
|
|
143
145
|
"postal_code",
|
|
144
146
|
"country",
|
|
@@ -152,7 +154,7 @@ function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
|
152
154
|
const { long_name: long_name2, short_name: short_name2 } = (_a = addressComponentMap[type]) != null ? _a : {};
|
|
153
155
|
if (!long_name2 && !short_name2)
|
|
154
156
|
continue;
|
|
155
|
-
const replacedName2 = result.replace(long_name2, "").replace(short_name2, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
157
|
+
const replacedName2 = result.replace(long_name2 != null ? long_name2 : EMPTY_REGEX, "").replace(short_name2 != null ? short_name2 : EMPTY_REGEX, "").replace(POSTAL_CODE_ZH_DESC, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
156
158
|
if (!replacedName2)
|
|
157
159
|
return result;
|
|
158
160
|
result = replacedName2;
|
|
@@ -162,7 +164,7 @@ function gmapPlaceName2DisplayName(name, addressComponents) {
|
|
|
162
164
|
const { long_name, short_name } = (_b = addressComponentMap["locality"]) != null ? _b : {};
|
|
163
165
|
if (!long_name && !short_name)
|
|
164
166
|
return result;
|
|
165
|
-
const replacedName = result.replace(long_name, "").replace(short_name, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
167
|
+
const replacedName = result.replace(long_name != null ? long_name : EMPTY_REGEX, "").replace(short_name != null ? short_name : EMPTY_REGEX, "").replace(POSTAL_CODE_ZH_DESC, "").replace(GMAP_USELESS_SYMBOL_AT_BOTH_ENDS_REGEX, "");
|
|
166
168
|
return replacedName ? replacedName : result;
|
|
167
169
|
}
|
|
168
170
|
function gmapAddressComponentList2AddressComponentMap(addressComponents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycar/heycars-map",
|
|
3
|
-
"version": "0.11.0-
|
|
3
|
+
"version": "0.11.0-google3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"checkVersion": "./bin/checkVersion.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lodash-es": "^4.17.21",
|
|
49
49
|
"vue-demi": "^0.13.11",
|
|
50
50
|
"vue2": "npm:vue@2.7.14",
|
|
51
|
-
"vue3": "npm:vue
|
|
51
|
+
"vue3": "npm:vue@3.4.21"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@vue/composition-api": "^1.0.0-rc.1",
|