@fleet-frontend/mower-maps 0.2.5-beta.20 → 0.2.5-beta.22
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/context/common.d.ts +8 -0
- package/dist/context/common.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +272 -72
- package/dist/index.js +273 -71
- package/dist/render/MowerMapRenderer.d.ts.map +1 -1
- package/dist/render/svgElement/PolygonELement/components/Magnifier/index.d.ts.map +1 -1
- package/dist/types/renderer.d.ts +9 -0
- package/dist/types/renderer.d.ts.map +1 -1
- package/dist/utils/googleStaticMapSign.d.ts +17 -0
- package/dist/utils/googleStaticMapSign.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/context/common.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ interface CommonContextType {
|
|
|
29
29
|
overlayLayout?: Record<string, any> | null;
|
|
30
30
|
bounds?: any;
|
|
31
31
|
googleMapStaticApiKey?: string;
|
|
32
|
+
/** Maps Static API URL 签名密钥,见 signGoogleStaticMapUrl 工具 */
|
|
33
|
+
googleMapStaticUrlSigningSecret?: string;
|
|
34
|
+
/** 宿主服务端签名回调(优先于 googleMapStaticUrlSigningSecret) */
|
|
35
|
+
signGoogleStaticMapUrl?: (unsignedUrl: string) => Promise<string> | string;
|
|
32
36
|
onH5FirstSelectObstaclePoint?: () => void;
|
|
33
37
|
}
|
|
34
38
|
export declare const CommonContext: import("react").Context<{
|
|
@@ -57,6 +61,8 @@ export declare const CommonContext: import("react").Context<{
|
|
|
57
61
|
overlayScale: number;
|
|
58
62
|
showStraddleBoundaryBorder: boolean;
|
|
59
63
|
googleMapStaticApiKey: string;
|
|
64
|
+
googleMapStaticUrlSigningSecret: string;
|
|
65
|
+
signGoogleStaticMapUrl: any;
|
|
60
66
|
onH5FirstSelectObstaclePoint: any;
|
|
61
67
|
}>;
|
|
62
68
|
export declare const CommonContextProvider: import("react").Provider<{
|
|
@@ -85,6 +91,8 @@ export declare const CommonContextProvider: import("react").Provider<{
|
|
|
85
91
|
overlayScale: number;
|
|
86
92
|
showStraddleBoundaryBorder: boolean;
|
|
87
93
|
googleMapStaticApiKey: string;
|
|
94
|
+
googleMapStaticUrlSigningSecret: string;
|
|
95
|
+
signGoogleStaticMapUrl: any;
|
|
88
96
|
onH5FirstSelectObstaclePoint: any;
|
|
89
97
|
}>;
|
|
90
98
|
export declare const useCommonContext: () => CommonContextType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/context/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,MAAM,EAAE,GAAG,CAAC;IACZ,YAAY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,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,qDAAqD;IACrD,sBAAsB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC3E,4BAA4B,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3C;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBxB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAyB,CAAC;AAE5D,eAAO,MAAM,gBAAgB,yBAAqD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type { PathConfig as DataPathConfig } from './processor';
|
|
|
12
12
|
export * from './processor';
|
|
13
13
|
export { calculateMapGpsCenter, estimateGpsFromMapBounds, getValidGpsBounds, } from './utils/mapBounds';
|
|
14
14
|
export { restorePointsFormat } from './utils/coordinates';
|
|
15
|
+
export { signGoogleStaticMapUrl, signGoogleStaticMapUrlSync } from './utils/googleStaticMapSign';
|
|
15
16
|
export { SvgParserNative } from './utils/svgParserNative';
|
|
16
17
|
export { SCALE_FACTOR } from './config';
|
|
17
18
|
export { ALL_DIRECTION_SELECTED, MAX_DIRECTION_ANGLE, MIN_DIRECTION_ANGLE } from './config';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,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B,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -22691,6 +22691,8 @@ const CommonContext = createContext({
|
|
|
22691
22691
|
overlayScale: 1,
|
|
22692
22692
|
showStraddleBoundaryBorder: true,
|
|
22693
22693
|
googleMapStaticApiKey: '',
|
|
22694
|
+
googleMapStaticUrlSigningSecret: '',
|
|
22695
|
+
signGoogleStaticMapUrl: undefined,
|
|
22694
22696
|
onH5FirstSelectObstaclePoint: undefined,
|
|
22695
22697
|
});
|
|
22696
22698
|
const CommonContextProvider = CommonContext.Provider;
|
|
@@ -23172,6 +23174,167 @@ const MapEditContext = createContext({
|
|
|
23172
23174
|
const MapEditContextProvider = MapEditContext.Provider;
|
|
23173
23175
|
const useMapEditContext = () => useContext(MapEditContext);
|
|
23174
23176
|
|
|
23177
|
+
/**
|
|
23178
|
+
* Google Maps Static API 数字签名
|
|
23179
|
+
* @see https://developers.google.com/maps/documentation/maps-static/digital-signature
|
|
23180
|
+
*
|
|
23181
|
+
* 使用纯 JS HMAC-SHA1,兼容 H5 WebView / 非 HTTPS 等无 crypto.subtle 的环境。
|
|
23182
|
+
*/
|
|
23183
|
+
/// <reference lib="dom" />
|
|
23184
|
+
function removeWebSafe(encoded) {
|
|
23185
|
+
return encoded.replace(/-/g, '+').replace(/_/g, '/');
|
|
23186
|
+
}
|
|
23187
|
+
function makeWebSafe(encoded) {
|
|
23188
|
+
return encoded.replace(/\+/g, '-').replace(/\//g, '_');
|
|
23189
|
+
}
|
|
23190
|
+
function decodeUrlSigningSecret(secret) {
|
|
23191
|
+
let base64 = removeWebSafe(secret);
|
|
23192
|
+
const remainder = base64.length % 4;
|
|
23193
|
+
if (remainder) {
|
|
23194
|
+
base64 += '='.repeat(4 - remainder);
|
|
23195
|
+
}
|
|
23196
|
+
const binary = globalThis.atob(base64);
|
|
23197
|
+
const bytes = new Uint8Array(binary.length);
|
|
23198
|
+
for (let i = 0; i < binary.length; i++) {
|
|
23199
|
+
bytes[i] = binary.charCodeAt(i);
|
|
23200
|
+
}
|
|
23201
|
+
return bytes;
|
|
23202
|
+
}
|
|
23203
|
+
function bytesToWebSafeBase64(bytes) {
|
|
23204
|
+
let binary = '';
|
|
23205
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
23206
|
+
binary += String.fromCharCode(bytes[i]);
|
|
23207
|
+
}
|
|
23208
|
+
return makeWebSafe(globalThis.btoa(binary));
|
|
23209
|
+
}
|
|
23210
|
+
function utf8Encode(text) {
|
|
23211
|
+
return new globalThis.TextEncoder().encode(text);
|
|
23212
|
+
}
|
|
23213
|
+
function concatBytes(...parts) {
|
|
23214
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
23215
|
+
const out = new Uint8Array(total);
|
|
23216
|
+
let offset = 0;
|
|
23217
|
+
for (const part of parts) {
|
|
23218
|
+
out.set(part, offset);
|
|
23219
|
+
offset += part.length;
|
|
23220
|
+
}
|
|
23221
|
+
return out;
|
|
23222
|
+
}
|
|
23223
|
+
function leftRotate(value, amount) {
|
|
23224
|
+
return ((value << amount) | (value >>> (32 - amount))) >>> 0;
|
|
23225
|
+
}
|
|
23226
|
+
function sha1(message) {
|
|
23227
|
+
const originalLength = message.length;
|
|
23228
|
+
const bitLength = originalLength * 8;
|
|
23229
|
+
const paddedLength = Math.ceil((originalLength + 9) / 64) * 64;
|
|
23230
|
+
const padded = new Uint8Array(paddedLength);
|
|
23231
|
+
padded.set(message);
|
|
23232
|
+
padded[originalLength] = 0x80;
|
|
23233
|
+
const view = new DataView(padded.buffer);
|
|
23234
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
23235
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000), false);
|
|
23236
|
+
let h0 = 0x67452301;
|
|
23237
|
+
let h1 = 0xefcdab89;
|
|
23238
|
+
let h2 = 0x98badcfe;
|
|
23239
|
+
let h3 = 0x10325476;
|
|
23240
|
+
let h4 = 0xc3d2e1f0;
|
|
23241
|
+
const w = new Uint32Array(80);
|
|
23242
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
23243
|
+
for (let i = 0; i < 16; i++) {
|
|
23244
|
+
w[i] = view.getUint32(offset + i * 4, false);
|
|
23245
|
+
}
|
|
23246
|
+
for (let i = 16; i < 80; i++) {
|
|
23247
|
+
w[i] = leftRotate(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
23248
|
+
}
|
|
23249
|
+
let a = h0;
|
|
23250
|
+
let b = h1;
|
|
23251
|
+
let c = h2;
|
|
23252
|
+
let d = h3;
|
|
23253
|
+
let e = h4;
|
|
23254
|
+
for (let i = 0; i < 80; i++) {
|
|
23255
|
+
let f;
|
|
23256
|
+
let k;
|
|
23257
|
+
if (i < 20) {
|
|
23258
|
+
f = (b & c) | (~b & d);
|
|
23259
|
+
k = 0x5a827999;
|
|
23260
|
+
}
|
|
23261
|
+
else if (i < 40) {
|
|
23262
|
+
f = b ^ c ^ d;
|
|
23263
|
+
k = 0x6ed9eba1;
|
|
23264
|
+
}
|
|
23265
|
+
else if (i < 60) {
|
|
23266
|
+
f = (b & c) | (b & d) | (c & d);
|
|
23267
|
+
k = 0x8f1bbcdc;
|
|
23268
|
+
}
|
|
23269
|
+
else {
|
|
23270
|
+
f = b ^ c ^ d;
|
|
23271
|
+
k = 0xca62c1d6;
|
|
23272
|
+
}
|
|
23273
|
+
const temp = (leftRotate(a, 5) + f + e + k + w[i]) >>> 0;
|
|
23274
|
+
e = d;
|
|
23275
|
+
d = c;
|
|
23276
|
+
c = leftRotate(b, 30);
|
|
23277
|
+
b = a;
|
|
23278
|
+
a = temp;
|
|
23279
|
+
}
|
|
23280
|
+
h0 = (h0 + a) >>> 0;
|
|
23281
|
+
h1 = (h1 + b) >>> 0;
|
|
23282
|
+
h2 = (h2 + c) >>> 0;
|
|
23283
|
+
h3 = (h3 + d) >>> 0;
|
|
23284
|
+
h4 = (h4 + e) >>> 0;
|
|
23285
|
+
}
|
|
23286
|
+
const digest = new Uint8Array(20);
|
|
23287
|
+
const digestView = new DataView(digest.buffer);
|
|
23288
|
+
digestView.setUint32(0, h0, false);
|
|
23289
|
+
digestView.setUint32(4, h1, false);
|
|
23290
|
+
digestView.setUint32(8, h2, false);
|
|
23291
|
+
digestView.setUint32(12, h3, false);
|
|
23292
|
+
digestView.setUint32(16, h4, false);
|
|
23293
|
+
return digest;
|
|
23294
|
+
}
|
|
23295
|
+
function hmacSha1(key, message) {
|
|
23296
|
+
const blockSize = 64;
|
|
23297
|
+
let normalizedKey = key;
|
|
23298
|
+
if (normalizedKey.length > blockSize) {
|
|
23299
|
+
normalizedKey = sha1(normalizedKey);
|
|
23300
|
+
}
|
|
23301
|
+
const paddedKey = new Uint8Array(blockSize);
|
|
23302
|
+
paddedKey.set(normalizedKey);
|
|
23303
|
+
const innerPad = new Uint8Array(blockSize);
|
|
23304
|
+
const outerPad = new Uint8Array(blockSize);
|
|
23305
|
+
for (let i = 0; i < blockSize; i++) {
|
|
23306
|
+
innerPad[i] = paddedKey[i] ^ 0x36;
|
|
23307
|
+
outerPad[i] = paddedKey[i] ^ 0x5c;
|
|
23308
|
+
}
|
|
23309
|
+
return sha1(concatBytes(outerPad, sha1(concatBytes(innerPad, message))));
|
|
23310
|
+
}
|
|
23311
|
+
function signUrlToSign(urlToSign, urlSigningSecret) {
|
|
23312
|
+
const keyBytes = decodeUrlSigningSecret(urlSigningSecret);
|
|
23313
|
+
const signatureBytes = hmacSha1(keyBytes, utf8Encode(urlToSign));
|
|
23314
|
+
return bytesToWebSafeBase64(signatureBytes);
|
|
23315
|
+
}
|
|
23316
|
+
/**
|
|
23317
|
+
* 对 Maps Static API 请求 URL 追加 `signature` 参数。
|
|
23318
|
+
* 签名内容为 pathname + search(不含 scheme/host),算法 HMAC-SHA1 + URL-safe Base64。
|
|
23319
|
+
*
|
|
23320
|
+
* @param inputUrl 完整未签名 URL(须已包含 key 等 query 参数)
|
|
23321
|
+
* @param urlSigningSecret Cloud Console「URL 签名密钥」(URL-safe Base64)
|
|
23322
|
+
*/
|
|
23323
|
+
function signGoogleStaticMapUrlSync(inputUrl, urlSigningSecret) {
|
|
23324
|
+
if (!inputUrl || !urlSigningSecret) {
|
|
23325
|
+
throw new Error('signGoogleStaticMapUrl: inputUrl and urlSigningSecret are required');
|
|
23326
|
+
}
|
|
23327
|
+
const url = new globalThis.URL(inputUrl);
|
|
23328
|
+
url.searchParams.delete('signature');
|
|
23329
|
+
const urlToSign = `${url.pathname}${url.search}`;
|
|
23330
|
+
const signature = signUrlToSign(urlToSign, urlSigningSecret);
|
|
23331
|
+
return `${url.origin}${urlToSign}&signature=${signature}`;
|
|
23332
|
+
}
|
|
23333
|
+
/** 异步包装,便于与宿主 signGoogleStaticMapUrl 回调统一 Promise 接口 */
|
|
23334
|
+
async function signGoogleStaticMapUrl(inputUrl, urlSigningSecret) {
|
|
23335
|
+
return signGoogleStaticMapUrlSync(inputUrl, urlSigningSecret);
|
|
23336
|
+
}
|
|
23337
|
+
|
|
23175
23338
|
var chargingPileImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABHHSURBVHgBtVtdjF3VdV7rnHPHtLbUkRrALwmDidSSgD1JqWQ3UMaNMaFq63FIKyoVZFRF6kMkbCmVcP9mrBARoJUnLRL9c+3WSVsqIkwrtRBKfaGmQFuFazBpK0wYnmLSF6MYx557zt5Zv3vvO/Z4bDPZ9pl97rlnztnfXmt969s/g/AjKrN7nxwf634wBTFMYIQNAWASAcYjxAmI+T5EnAeIdFQnYwxHqwr6Z5s1g9ld20/Cj6AgrGBhkKva0/d1MUxBiFMxEjw7gGv5RyUWL+cfiCD/0I4KoULs04ensKkP7d716/OwQmVFAD/4yMGpLsJM7MJUiIGMGiDQwUBDYHR8DgocFG/54gQ0HRVUFQPnuoK6q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YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
|
|
23176
23339
|
|
|
23177
23340
|
const useChargingPile = ({ viewBox, rotation = 0 }) => {
|
|
@@ -23249,7 +23412,7 @@ const STATIC_MAP_RETRY_COOLDOWN_MS = 5000;
|
|
|
23249
23412
|
/** 放大镜内充电桩屏幕像素下限,避免过小导致通道与桩视觉错位 */
|
|
23250
23413
|
const MAGNIFIER_CHARGING_PILE_MIN_DISPLAY_PX = 20;
|
|
23251
23414
|
const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 122, 51, 0.1)', strokeColor = 'rgba(255, 122, 51, 1)', strokeWidth = 2, zoom = 3, size = 200, }) => {
|
|
23252
|
-
const { svgViewBox, mapRef, googleMapStaticApiKey, drag } = useCommonContext();
|
|
23415
|
+
const { svgViewBox, mapRef, googleMapStaticApiKey, googleMapStaticUrlSigningSecret, signGoogleStaticMapUrl: signGoogleStaticMapUrl$1, drag, } = useCommonContext();
|
|
23253
23416
|
const { svgElementDatas, svgRef } = useSvgEditContext();
|
|
23254
23417
|
const { editMapInfo } = useMapEditContext();
|
|
23255
23418
|
const [magnifierPosition, setMagnifierPosition] = useState({ x: 0, y: 0 });
|
|
@@ -23337,76 +23500,107 @@ const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 1
|
|
|
23337
23500
|
const svgPoint = svgRef.createSVGPoint();
|
|
23338
23501
|
// 只要有 key 就尝试 static api;请求失败时不截图,直接回退灰色背景
|
|
23339
23502
|
if (googleMapStaticApiKey) {
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23503
|
+
let cancelled = false;
|
|
23504
|
+
(async () => {
|
|
23505
|
+
// console.log('[Magnifier] Background source: static api viewport snapshot');
|
|
23506
|
+
const mapBounds = mapRef.getBounds?.();
|
|
23507
|
+
if (!mapBounds) {
|
|
23508
|
+
// console.log('[Magnifier] Skip static map effect: mapBounds missing');
|
|
23509
|
+
if (!cancelled) {
|
|
23510
|
+
setMapImageFrame(null);
|
|
23511
|
+
}
|
|
23512
|
+
return;
|
|
23513
|
+
}
|
|
23514
|
+
const screenToSvg = (screenX, screenY) => {
|
|
23515
|
+
svgPoint.x = screenX;
|
|
23516
|
+
svgPoint.y = screenY;
|
|
23517
|
+
const p = svgPoint.matrixTransform(inverseCtm);
|
|
23518
|
+
return { x: p.x, y: p.y };
|
|
23519
|
+
};
|
|
23520
|
+
// 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
|
|
23521
|
+
const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
|
|
23522
|
+
const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
|
|
23523
|
+
const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
|
|
23524
|
+
if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
|
|
23525
|
+
if (!cancelled) {
|
|
23526
|
+
setMapImageFrame(null);
|
|
23527
|
+
}
|
|
23528
|
+
return;
|
|
23529
|
+
}
|
|
23530
|
+
// 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
|
|
23531
|
+
const mapWidth = Math.max(1, Math.round(mapRect.width));
|
|
23532
|
+
const mapHeight = Math.max(1, Math.round(mapRect.height));
|
|
23533
|
+
const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
|
|
23534
|
+
const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
|
|
23535
|
+
const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
|
|
23536
|
+
const center = mapBounds.getCenter();
|
|
23537
|
+
const currentZoom = mapRef.getZoom() || 20;
|
|
23538
|
+
// 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
|
|
23539
|
+
const zoomCompensation = Math.log2(shrinkRatio);
|
|
23540
|
+
const adjustedZoom = currentZoom + zoomCompensation;
|
|
23541
|
+
const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
|
|
23542
|
+
const unsignedStaticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
|
|
23543
|
+
// 可选:对 Static Map URL 做 Google 数字签名(宿主回调优先,其次客户端 signing secret)
|
|
23544
|
+
let staticMapUrl = unsignedStaticMapUrl;
|
|
23545
|
+
try {
|
|
23546
|
+
if (signGoogleStaticMapUrl$1) {
|
|
23547
|
+
staticMapUrl = await Promise.resolve(signGoogleStaticMapUrl$1(unsignedStaticMapUrl));
|
|
23548
|
+
}
|
|
23549
|
+
else if (googleMapStaticUrlSigningSecret) {
|
|
23550
|
+
staticMapUrl = await signGoogleStaticMapUrl(unsignedStaticMapUrl, googleMapStaticUrlSigningSecret);
|
|
23551
|
+
console.log('[Magnifier] staticMapUrl', staticMapUrl);
|
|
23552
|
+
}
|
|
23553
|
+
}
|
|
23554
|
+
catch (error) {
|
|
23555
|
+
console.warn('[Magnifier] Static map URL signing failed', error);
|
|
23556
|
+
if (!cancelled) {
|
|
23557
|
+
setMapImageFrame(null);
|
|
23558
|
+
}
|
|
23559
|
+
return;
|
|
23560
|
+
}
|
|
23561
|
+
// 通过三角点推导静态图在 SVG 中的宽高和旋转角
|
|
23562
|
+
// Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
|
|
23563
|
+
const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
|
|
23564
|
+
const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
|
|
23565
|
+
// Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
|
|
23566
|
+
const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
|
|
23567
|
+
// Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
|
|
23568
|
+
// 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
|
|
23569
|
+
const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
|
|
23570
|
+
//把原始 width/height 乘这个比例,得到补偿后的尺寸。
|
|
23571
|
+
const compensatedWidth = width * fractionalZoomScale;
|
|
23572
|
+
const compensatedHeight = height * fractionalZoomScale;
|
|
23573
|
+
//尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
|
|
23574
|
+
const offsetAlongX = (compensatedWidth - width) / 2;
|
|
23575
|
+
const offsetAlongY = (compensatedHeight - height) / 2;
|
|
23576
|
+
//“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
|
|
23577
|
+
const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
|
|
23578
|
+
const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
|
|
23579
|
+
//“下方向”单位向量(从左上指向左下),同理用于旋转场景。
|
|
23580
|
+
const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
|
|
23581
|
+
const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 0;
|
|
23582
|
+
/**
|
|
23583
|
+
* 计算补偿后的新左上角:
|
|
23584
|
+
* 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
|
|
23585
|
+
* 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
|
|
23586
|
+
*/
|
|
23587
|
+
const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
|
|
23588
|
+
const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
|
|
23589
|
+
if (cancelled) {
|
|
23590
|
+
return;
|
|
23591
|
+
}
|
|
23592
|
+
setMapImageFrame({
|
|
23593
|
+
url: staticMapUrl,
|
|
23594
|
+
x: compensatedTopLeftX,
|
|
23595
|
+
y: compensatedTopLeftY,
|
|
23596
|
+
width: compensatedWidth,
|
|
23597
|
+
height: compensatedHeight,
|
|
23598
|
+
transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
|
|
23599
|
+
});
|
|
23600
|
+
})();
|
|
23601
|
+
return () => {
|
|
23602
|
+
cancelled = true;
|
|
23352
23603
|
};
|
|
23353
|
-
// 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
|
|
23354
|
-
const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
|
|
23355
|
-
const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
|
|
23356
|
-
const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
|
|
23357
|
-
if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
|
|
23358
|
-
setMapImageFrame(null);
|
|
23359
|
-
return;
|
|
23360
|
-
}
|
|
23361
|
-
// 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
|
|
23362
|
-
const mapWidth = Math.max(1, Math.round(mapRect.width));
|
|
23363
|
-
const mapHeight = Math.max(1, Math.round(mapRect.height));
|
|
23364
|
-
const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
|
|
23365
|
-
const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
|
|
23366
|
-
const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
|
|
23367
|
-
const center = mapBounds.getCenter();
|
|
23368
|
-
const currentZoom = mapRef.getZoom() || 20;
|
|
23369
|
-
// 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
|
|
23370
|
-
const zoomCompensation = Math.log2(shrinkRatio);
|
|
23371
|
-
const adjustedZoom = currentZoom + zoomCompensation;
|
|
23372
|
-
const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
|
|
23373
|
-
const staticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
|
|
23374
|
-
// 通过三角点推导静态图在 SVG 中的宽高和旋转角
|
|
23375
|
-
// Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
|
|
23376
|
-
const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
|
|
23377
|
-
const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
|
|
23378
|
-
// Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
|
|
23379
|
-
const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
|
|
23380
|
-
// Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
|
|
23381
|
-
// 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
|
|
23382
|
-
const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
|
|
23383
|
-
//把原始 width/height 乘这个比例,得到补偿后的尺寸。
|
|
23384
|
-
const compensatedWidth = width * fractionalZoomScale;
|
|
23385
|
-
const compensatedHeight = height * fractionalZoomScale;
|
|
23386
|
-
//尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
|
|
23387
|
-
const offsetAlongX = (compensatedWidth - width) / 2;
|
|
23388
|
-
const offsetAlongY = (compensatedHeight - height) / 2;
|
|
23389
|
-
//“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
|
|
23390
|
-
const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
|
|
23391
|
-
const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
|
|
23392
|
-
//“下方向”单位向量(从左上指向左下),同理用于旋转场景。
|
|
23393
|
-
const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
|
|
23394
|
-
const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 1;
|
|
23395
|
-
/**
|
|
23396
|
-
* 计算补偿后的新左上角:
|
|
23397
|
-
* 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
|
|
23398
|
-
* 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
|
|
23399
|
-
*/
|
|
23400
|
-
const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
|
|
23401
|
-
const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
|
|
23402
|
-
setMapImageFrame({
|
|
23403
|
-
url: staticMapUrl,
|
|
23404
|
-
x: compensatedTopLeftX,
|
|
23405
|
-
y: compensatedTopLeftY,
|
|
23406
|
-
width: compensatedWidth,
|
|
23407
|
-
height: compensatedHeight,
|
|
23408
|
-
transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
|
|
23409
|
-
});
|
|
23410
23604
|
}
|
|
23411
23605
|
else {
|
|
23412
23606
|
setMapImageFrame(null);
|
|
@@ -23426,6 +23620,8 @@ const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 1
|
|
|
23426
23620
|
size,
|
|
23427
23621
|
zoom,
|
|
23428
23622
|
googleMapStaticApiKey,
|
|
23623
|
+
googleMapStaticUrlSigningSecret,
|
|
23624
|
+
signGoogleStaticMapUrl$1,
|
|
23429
23625
|
staticMapRetryCount,
|
|
23430
23626
|
staticMapBlockedUntil,
|
|
23431
23627
|
]);
|
|
@@ -29564,7 +29760,7 @@ const defaultMapConfig$1 = DEFAULT_STYLES;
|
|
|
29564
29760
|
// 地图渲染器组件
|
|
29565
29761
|
const MowerMapRenderer = forwardRef(({ sn, mowerIconConfig = {}, platform = PlatformType.WEB, mapType = MapType.NORMAL, edger = false, unitType = UnitsType.Imperial, language = 'en', onlyRead = false, isHighlight = true, mapConfig,
|
|
29566
29762
|
// pathConfig,
|
|
29567
|
-
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, zIndex, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, googleMapStaticApiKey, onHandleEvent, onSelectElement, onH5FirstSelectObstaclePoint, }, ref) => {
|
|
29763
|
+
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, zIndex, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, googleMapStaticApiKey, googleMapStaticUrlSigningSecret, signGoogleStaticMapUrl, onHandleEvent, onSelectElement, onH5FirstSelectObstaclePoint, }, ref) => {
|
|
29568
29764
|
const [currentError, setCurrentError] = useState(null);
|
|
29569
29765
|
// const mapRef = useMap();
|
|
29570
29766
|
const [processStateIsMowing, setProcessStateIsMowing] = useState(false);
|
|
@@ -29810,6 +30006,8 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29810
30006
|
showStraddleBoundaryBorder,
|
|
29811
30007
|
overlayLayout,
|
|
29812
30008
|
googleMapStaticApiKey,
|
|
30009
|
+
googleMapStaticUrlSigningSecret,
|
|
30010
|
+
signGoogleStaticMapUrl,
|
|
29813
30011
|
onH5FirstSelectObstaclePoint,
|
|
29814
30012
|
};
|
|
29815
30013
|
}, [
|
|
@@ -29833,6 +30031,8 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29833
30031
|
showStraddleBoundaryBorder,
|
|
29834
30032
|
overlayLayout,
|
|
29835
30033
|
googleMapStaticApiKey,
|
|
30034
|
+
googleMapStaticUrlSigningSecret,
|
|
30035
|
+
signGoogleStaticMapUrl,
|
|
29836
30036
|
onH5FirstSelectObstaclePoint,
|
|
29837
30037
|
]);
|
|
29838
30038
|
/**
|
|
@@ -30281,4 +30481,4 @@ const BoundarySvgRender = React__default.memo(({ mapJson, unStructMapData, id, m
|
|
|
30281
30481
|
}) }), jsx(CharginPile, { viewBox: boundaryViewBox || null, rotation: 0 })] }) }) }));
|
|
30282
30482
|
});
|
|
30283
30483
|
|
|
30284
|
-
export { ALL_DIRECTION_SELECTED, AntennaData, BaseData, BoundaryData, BoundarySvgRender, ChannelData, ChargingPileData, CheckDoodleErrorType, CheckObstaclePointErrorType, ClickEventType, CreateStatus, DataType, DoodleData, MAX_DIRECTION_ANGLE, MIN_DIRECTION_ANGLE, MapType, MobileEditMode, MowGateData, MowerMapRenderer, ObstacleData, PathData, PlatformType, RecordFunctionEnum, RecordTypeEnum, RenderType, SCALE_FACTOR, SvgParserNative, UnifiedMapDataProcessor, VisionOffData, calculateMapGpsCenter, estimateGpsFromMapBounds, getValidGpsBounds, initBoundary, initChannel, initDoodle, initObstacle, initVisionOff, restorePointsFormat };
|
|
30484
|
+
export { ALL_DIRECTION_SELECTED, AntennaData, BaseData, BoundaryData, BoundarySvgRender, ChannelData, ChargingPileData, CheckDoodleErrorType, CheckObstaclePointErrorType, ClickEventType, CreateStatus, DataType, DoodleData, MAX_DIRECTION_ANGLE, MIN_DIRECTION_ANGLE, MapType, MobileEditMode, MowGateData, MowerMapRenderer, ObstacleData, PathData, PlatformType, RecordFunctionEnum, RecordTypeEnum, RenderType, SCALE_FACTOR, SvgParserNative, UnifiedMapDataProcessor, VisionOffData, calculateMapGpsCenter, estimateGpsFromMapBounds, getValidGpsBounds, initBoundary, initChannel, initDoodle, initObstacle, initVisionOff, restorePointsFormat, signGoogleStaticMapUrl, signGoogleStaticMapUrlSync };
|
package/dist/index.js
CHANGED
|
@@ -22711,6 +22711,8 @@ const CommonContext = React.createContext({
|
|
|
22711
22711
|
overlayScale: 1,
|
|
22712
22712
|
showStraddleBoundaryBorder: true,
|
|
22713
22713
|
googleMapStaticApiKey: '',
|
|
22714
|
+
googleMapStaticUrlSigningSecret: '',
|
|
22715
|
+
signGoogleStaticMapUrl: undefined,
|
|
22714
22716
|
onH5FirstSelectObstaclePoint: undefined,
|
|
22715
22717
|
});
|
|
22716
22718
|
const CommonContextProvider = CommonContext.Provider;
|
|
@@ -23192,6 +23194,167 @@ const MapEditContext = React.createContext({
|
|
|
23192
23194
|
const MapEditContextProvider = MapEditContext.Provider;
|
|
23193
23195
|
const useMapEditContext = () => React.useContext(MapEditContext);
|
|
23194
23196
|
|
|
23197
|
+
/**
|
|
23198
|
+
* Google Maps Static API 数字签名
|
|
23199
|
+
* @see https://developers.google.com/maps/documentation/maps-static/digital-signature
|
|
23200
|
+
*
|
|
23201
|
+
* 使用纯 JS HMAC-SHA1,兼容 H5 WebView / 非 HTTPS 等无 crypto.subtle 的环境。
|
|
23202
|
+
*/
|
|
23203
|
+
/// <reference lib="dom" />
|
|
23204
|
+
function removeWebSafe(encoded) {
|
|
23205
|
+
return encoded.replace(/-/g, '+').replace(/_/g, '/');
|
|
23206
|
+
}
|
|
23207
|
+
function makeWebSafe(encoded) {
|
|
23208
|
+
return encoded.replace(/\+/g, '-').replace(/\//g, '_');
|
|
23209
|
+
}
|
|
23210
|
+
function decodeUrlSigningSecret(secret) {
|
|
23211
|
+
let base64 = removeWebSafe(secret);
|
|
23212
|
+
const remainder = base64.length % 4;
|
|
23213
|
+
if (remainder) {
|
|
23214
|
+
base64 += '='.repeat(4 - remainder);
|
|
23215
|
+
}
|
|
23216
|
+
const binary = globalThis.atob(base64);
|
|
23217
|
+
const bytes = new Uint8Array(binary.length);
|
|
23218
|
+
for (let i = 0; i < binary.length; i++) {
|
|
23219
|
+
bytes[i] = binary.charCodeAt(i);
|
|
23220
|
+
}
|
|
23221
|
+
return bytes;
|
|
23222
|
+
}
|
|
23223
|
+
function bytesToWebSafeBase64(bytes) {
|
|
23224
|
+
let binary = '';
|
|
23225
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
23226
|
+
binary += String.fromCharCode(bytes[i]);
|
|
23227
|
+
}
|
|
23228
|
+
return makeWebSafe(globalThis.btoa(binary));
|
|
23229
|
+
}
|
|
23230
|
+
function utf8Encode(text) {
|
|
23231
|
+
return new globalThis.TextEncoder().encode(text);
|
|
23232
|
+
}
|
|
23233
|
+
function concatBytes(...parts) {
|
|
23234
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
23235
|
+
const out = new Uint8Array(total);
|
|
23236
|
+
let offset = 0;
|
|
23237
|
+
for (const part of parts) {
|
|
23238
|
+
out.set(part, offset);
|
|
23239
|
+
offset += part.length;
|
|
23240
|
+
}
|
|
23241
|
+
return out;
|
|
23242
|
+
}
|
|
23243
|
+
function leftRotate(value, amount) {
|
|
23244
|
+
return ((value << amount) | (value >>> (32 - amount))) >>> 0;
|
|
23245
|
+
}
|
|
23246
|
+
function sha1(message) {
|
|
23247
|
+
const originalLength = message.length;
|
|
23248
|
+
const bitLength = originalLength * 8;
|
|
23249
|
+
const paddedLength = Math.ceil((originalLength + 9) / 64) * 64;
|
|
23250
|
+
const padded = new Uint8Array(paddedLength);
|
|
23251
|
+
padded.set(message);
|
|
23252
|
+
padded[originalLength] = 0x80;
|
|
23253
|
+
const view = new DataView(padded.buffer);
|
|
23254
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
23255
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000), false);
|
|
23256
|
+
let h0 = 0x67452301;
|
|
23257
|
+
let h1 = 0xefcdab89;
|
|
23258
|
+
let h2 = 0x98badcfe;
|
|
23259
|
+
let h3 = 0x10325476;
|
|
23260
|
+
let h4 = 0xc3d2e1f0;
|
|
23261
|
+
const w = new Uint32Array(80);
|
|
23262
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
23263
|
+
for (let i = 0; i < 16; i++) {
|
|
23264
|
+
w[i] = view.getUint32(offset + i * 4, false);
|
|
23265
|
+
}
|
|
23266
|
+
for (let i = 16; i < 80; i++) {
|
|
23267
|
+
w[i] = leftRotate(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
23268
|
+
}
|
|
23269
|
+
let a = h0;
|
|
23270
|
+
let b = h1;
|
|
23271
|
+
let c = h2;
|
|
23272
|
+
let d = h3;
|
|
23273
|
+
let e = h4;
|
|
23274
|
+
for (let i = 0; i < 80; i++) {
|
|
23275
|
+
let f;
|
|
23276
|
+
let k;
|
|
23277
|
+
if (i < 20) {
|
|
23278
|
+
f = (b & c) | (~b & d);
|
|
23279
|
+
k = 0x5a827999;
|
|
23280
|
+
}
|
|
23281
|
+
else if (i < 40) {
|
|
23282
|
+
f = b ^ c ^ d;
|
|
23283
|
+
k = 0x6ed9eba1;
|
|
23284
|
+
}
|
|
23285
|
+
else if (i < 60) {
|
|
23286
|
+
f = (b & c) | (b & d) | (c & d);
|
|
23287
|
+
k = 0x8f1bbcdc;
|
|
23288
|
+
}
|
|
23289
|
+
else {
|
|
23290
|
+
f = b ^ c ^ d;
|
|
23291
|
+
k = 0xca62c1d6;
|
|
23292
|
+
}
|
|
23293
|
+
const temp = (leftRotate(a, 5) + f + e + k + w[i]) >>> 0;
|
|
23294
|
+
e = d;
|
|
23295
|
+
d = c;
|
|
23296
|
+
c = leftRotate(b, 30);
|
|
23297
|
+
b = a;
|
|
23298
|
+
a = temp;
|
|
23299
|
+
}
|
|
23300
|
+
h0 = (h0 + a) >>> 0;
|
|
23301
|
+
h1 = (h1 + b) >>> 0;
|
|
23302
|
+
h2 = (h2 + c) >>> 0;
|
|
23303
|
+
h3 = (h3 + d) >>> 0;
|
|
23304
|
+
h4 = (h4 + e) >>> 0;
|
|
23305
|
+
}
|
|
23306
|
+
const digest = new Uint8Array(20);
|
|
23307
|
+
const digestView = new DataView(digest.buffer);
|
|
23308
|
+
digestView.setUint32(0, h0, false);
|
|
23309
|
+
digestView.setUint32(4, h1, false);
|
|
23310
|
+
digestView.setUint32(8, h2, false);
|
|
23311
|
+
digestView.setUint32(12, h3, false);
|
|
23312
|
+
digestView.setUint32(16, h4, false);
|
|
23313
|
+
return digest;
|
|
23314
|
+
}
|
|
23315
|
+
function hmacSha1(key, message) {
|
|
23316
|
+
const blockSize = 64;
|
|
23317
|
+
let normalizedKey = key;
|
|
23318
|
+
if (normalizedKey.length > blockSize) {
|
|
23319
|
+
normalizedKey = sha1(normalizedKey);
|
|
23320
|
+
}
|
|
23321
|
+
const paddedKey = new Uint8Array(blockSize);
|
|
23322
|
+
paddedKey.set(normalizedKey);
|
|
23323
|
+
const innerPad = new Uint8Array(blockSize);
|
|
23324
|
+
const outerPad = new Uint8Array(blockSize);
|
|
23325
|
+
for (let i = 0; i < blockSize; i++) {
|
|
23326
|
+
innerPad[i] = paddedKey[i] ^ 0x36;
|
|
23327
|
+
outerPad[i] = paddedKey[i] ^ 0x5c;
|
|
23328
|
+
}
|
|
23329
|
+
return sha1(concatBytes(outerPad, sha1(concatBytes(innerPad, message))));
|
|
23330
|
+
}
|
|
23331
|
+
function signUrlToSign(urlToSign, urlSigningSecret) {
|
|
23332
|
+
const keyBytes = decodeUrlSigningSecret(urlSigningSecret);
|
|
23333
|
+
const signatureBytes = hmacSha1(keyBytes, utf8Encode(urlToSign));
|
|
23334
|
+
return bytesToWebSafeBase64(signatureBytes);
|
|
23335
|
+
}
|
|
23336
|
+
/**
|
|
23337
|
+
* 对 Maps Static API 请求 URL 追加 `signature` 参数。
|
|
23338
|
+
* 签名内容为 pathname + search(不含 scheme/host),算法 HMAC-SHA1 + URL-safe Base64。
|
|
23339
|
+
*
|
|
23340
|
+
* @param inputUrl 完整未签名 URL(须已包含 key 等 query 参数)
|
|
23341
|
+
* @param urlSigningSecret Cloud Console「URL 签名密钥」(URL-safe Base64)
|
|
23342
|
+
*/
|
|
23343
|
+
function signGoogleStaticMapUrlSync(inputUrl, urlSigningSecret) {
|
|
23344
|
+
if (!inputUrl || !urlSigningSecret) {
|
|
23345
|
+
throw new Error('signGoogleStaticMapUrl: inputUrl and urlSigningSecret are required');
|
|
23346
|
+
}
|
|
23347
|
+
const url = new globalThis.URL(inputUrl);
|
|
23348
|
+
url.searchParams.delete('signature');
|
|
23349
|
+
const urlToSign = `${url.pathname}${url.search}`;
|
|
23350
|
+
const signature = signUrlToSign(urlToSign, urlSigningSecret);
|
|
23351
|
+
return `${url.origin}${urlToSign}&signature=${signature}`;
|
|
23352
|
+
}
|
|
23353
|
+
/** 异步包装,便于与宿主 signGoogleStaticMapUrl 回调统一 Promise 接口 */
|
|
23354
|
+
async function signGoogleStaticMapUrl(inputUrl, urlSigningSecret) {
|
|
23355
|
+
return signGoogleStaticMapUrlSync(inputUrl, urlSigningSecret);
|
|
23356
|
+
}
|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C305GLx85obJjU8RuGl62bhJRxihk5H4zB6LpsoKNsYiRLH0eZGFkAY34KoYc25VyL5/WkipQXVjjtkxZud3yHybv3bgD+fhcgFzOTZ4+eQNnyDQWE/R69dGI5xCCY2knRKOc1JeqQBMX2aBlsavWbTr7AWakEAhJrEoMzBK+mnGUGK2NxYJ7NGFCjY9cWDuxHJ4EC6h/Nrd9+2l9dadbdpumDeX+ipjKDajmaKE0iVC1kkptUqnuFtoLbvvJNOyC4tUtG3ETWOxynssx3gf9R8Pm2r2EIXgxWC4JMBcfvXunTu6djhDi80TQ90aga2uv4Ivs0bfSZtHSQbLyMwSUekfruB0PF6ppMW8UVwAE9gebywlN66b3klilD2Pf31uDi6hLOvSi8u3X3t5sOGmT9FQqxqndk2iyZ50QKXjahPxqFrchL3WlQPS0Rkd9QgwG8DovujaUw4dlCnIqkiA+2NjzR2PH5x7Gi6xXLKFy3Lnb3xhOrRhL60tT3TFnwKIe/sejGDL6DpJgAXn+YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
|
|
23196
23359
|
|
|
23197
23360
|
const useChargingPile = ({ viewBox, rotation = 0 }) => {
|
|
@@ -23269,7 +23432,7 @@ const STATIC_MAP_RETRY_COOLDOWN_MS = 5000;
|
|
|
23269
23432
|
/** 放大镜内充电桩屏幕像素下限,避免过小导致通道与桩视觉错位 */
|
|
23270
23433
|
const MAGNIFIER_CHARGING_PILE_MIN_DISPLAY_PX = 20;
|
|
23271
23434
|
const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 122, 51, 0.1)', strokeColor = 'rgba(255, 122, 51, 1)', strokeWidth = 2, zoom = 3, size = 200, }) => {
|
|
23272
|
-
const { svgViewBox, mapRef, googleMapStaticApiKey, drag } = useCommonContext();
|
|
23435
|
+
const { svgViewBox, mapRef, googleMapStaticApiKey, googleMapStaticUrlSigningSecret, signGoogleStaticMapUrl: signGoogleStaticMapUrl$1, drag, } = useCommonContext();
|
|
23273
23436
|
const { svgElementDatas, svgRef } = useSvgEditContext();
|
|
23274
23437
|
const { editMapInfo } = useMapEditContext();
|
|
23275
23438
|
const [magnifierPosition, setMagnifierPosition] = React.useState({ x: 0, y: 0 });
|
|
@@ -23357,76 +23520,107 @@ const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 1
|
|
|
23357
23520
|
const svgPoint = svgRef.createSVGPoint();
|
|
23358
23521
|
// 只要有 key 就尝试 static api;请求失败时不截图,直接回退灰色背景
|
|
23359
23522
|
if (googleMapStaticApiKey) {
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
|
|
23523
|
+
let cancelled = false;
|
|
23524
|
+
(async () => {
|
|
23525
|
+
// console.log('[Magnifier] Background source: static api viewport snapshot');
|
|
23526
|
+
const mapBounds = mapRef.getBounds?.();
|
|
23527
|
+
if (!mapBounds) {
|
|
23528
|
+
// console.log('[Magnifier] Skip static map effect: mapBounds missing');
|
|
23529
|
+
if (!cancelled) {
|
|
23530
|
+
setMapImageFrame(null);
|
|
23531
|
+
}
|
|
23532
|
+
return;
|
|
23533
|
+
}
|
|
23534
|
+
const screenToSvg = (screenX, screenY) => {
|
|
23535
|
+
svgPoint.x = screenX;
|
|
23536
|
+
svgPoint.y = screenY;
|
|
23537
|
+
const p = svgPoint.matrixTransform(inverseCtm);
|
|
23538
|
+
return { x: p.x, y: p.y };
|
|
23539
|
+
};
|
|
23540
|
+
// 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
|
|
23541
|
+
const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
|
|
23542
|
+
const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
|
|
23543
|
+
const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
|
|
23544
|
+
if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
|
|
23545
|
+
if (!cancelled) {
|
|
23546
|
+
setMapImageFrame(null);
|
|
23547
|
+
}
|
|
23548
|
+
return;
|
|
23549
|
+
}
|
|
23550
|
+
// 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
|
|
23551
|
+
const mapWidth = Math.max(1, Math.round(mapRect.width));
|
|
23552
|
+
const mapHeight = Math.max(1, Math.round(mapRect.height));
|
|
23553
|
+
const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
|
|
23554
|
+
const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
|
|
23555
|
+
const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
|
|
23556
|
+
const center = mapBounds.getCenter();
|
|
23557
|
+
const currentZoom = mapRef.getZoom() || 20;
|
|
23558
|
+
// 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
|
|
23559
|
+
const zoomCompensation = Math.log2(shrinkRatio);
|
|
23560
|
+
const adjustedZoom = currentZoom + zoomCompensation;
|
|
23561
|
+
const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
|
|
23562
|
+
const unsignedStaticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
|
|
23563
|
+
// 可选:对 Static Map URL 做 Google 数字签名(宿主回调优先,其次客户端 signing secret)
|
|
23564
|
+
let staticMapUrl = unsignedStaticMapUrl;
|
|
23565
|
+
try {
|
|
23566
|
+
if (signGoogleStaticMapUrl$1) {
|
|
23567
|
+
staticMapUrl = await Promise.resolve(signGoogleStaticMapUrl$1(unsignedStaticMapUrl));
|
|
23568
|
+
}
|
|
23569
|
+
else if (googleMapStaticUrlSigningSecret) {
|
|
23570
|
+
staticMapUrl = await signGoogleStaticMapUrl(unsignedStaticMapUrl, googleMapStaticUrlSigningSecret);
|
|
23571
|
+
console.log('[Magnifier] staticMapUrl', staticMapUrl);
|
|
23572
|
+
}
|
|
23573
|
+
}
|
|
23574
|
+
catch (error) {
|
|
23575
|
+
console.warn('[Magnifier] Static map URL signing failed', error);
|
|
23576
|
+
if (!cancelled) {
|
|
23577
|
+
setMapImageFrame(null);
|
|
23578
|
+
}
|
|
23579
|
+
return;
|
|
23580
|
+
}
|
|
23581
|
+
// 通过三角点推导静态图在 SVG 中的宽高和旋转角
|
|
23582
|
+
// Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
|
|
23583
|
+
const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
|
|
23584
|
+
const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
|
|
23585
|
+
// Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
|
|
23586
|
+
const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
|
|
23587
|
+
// Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
|
|
23588
|
+
// 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
|
|
23589
|
+
const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
|
|
23590
|
+
//把原始 width/height 乘这个比例,得到补偿后的尺寸。
|
|
23591
|
+
const compensatedWidth = width * fractionalZoomScale;
|
|
23592
|
+
const compensatedHeight = height * fractionalZoomScale;
|
|
23593
|
+
//尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
|
|
23594
|
+
const offsetAlongX = (compensatedWidth - width) / 2;
|
|
23595
|
+
const offsetAlongY = (compensatedHeight - height) / 2;
|
|
23596
|
+
//“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
|
|
23597
|
+
const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
|
|
23598
|
+
const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
|
|
23599
|
+
//“下方向”单位向量(从左上指向左下),同理用于旋转场景。
|
|
23600
|
+
const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
|
|
23601
|
+
const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 0;
|
|
23602
|
+
/**
|
|
23603
|
+
* 计算补偿后的新左上角:
|
|
23604
|
+
* 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
|
|
23605
|
+
* 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
|
|
23606
|
+
*/
|
|
23607
|
+
const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
|
|
23608
|
+
const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
|
|
23609
|
+
if (cancelled) {
|
|
23610
|
+
return;
|
|
23611
|
+
}
|
|
23612
|
+
setMapImageFrame({
|
|
23613
|
+
url: staticMapUrl,
|
|
23614
|
+
x: compensatedTopLeftX,
|
|
23615
|
+
y: compensatedTopLeftY,
|
|
23616
|
+
width: compensatedWidth,
|
|
23617
|
+
height: compensatedHeight,
|
|
23618
|
+
transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
|
|
23619
|
+
});
|
|
23620
|
+
})();
|
|
23621
|
+
return () => {
|
|
23622
|
+
cancelled = true;
|
|
23372
23623
|
};
|
|
23373
|
-
// 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
|
|
23374
|
-
const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
|
|
23375
|
-
const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
|
|
23376
|
-
const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
|
|
23377
|
-
if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
|
|
23378
|
-
setMapImageFrame(null);
|
|
23379
|
-
return;
|
|
23380
|
-
}
|
|
23381
|
-
// 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
|
|
23382
|
-
const mapWidth = Math.max(1, Math.round(mapRect.width));
|
|
23383
|
-
const mapHeight = Math.max(1, Math.round(mapRect.height));
|
|
23384
|
-
const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
|
|
23385
|
-
const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
|
|
23386
|
-
const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
|
|
23387
|
-
const center = mapBounds.getCenter();
|
|
23388
|
-
const currentZoom = mapRef.getZoom() || 20;
|
|
23389
|
-
// 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
|
|
23390
|
-
const zoomCompensation = Math.log2(shrinkRatio);
|
|
23391
|
-
const adjustedZoom = currentZoom + zoomCompensation;
|
|
23392
|
-
const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
|
|
23393
|
-
const staticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
|
|
23394
|
-
// 通过三角点推导静态图在 SVG 中的宽高和旋转角
|
|
23395
|
-
// Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
|
|
23396
|
-
const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
|
|
23397
|
-
const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
|
|
23398
|
-
// Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
|
|
23399
|
-
const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
|
|
23400
|
-
// Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
|
|
23401
|
-
// 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
|
|
23402
|
-
const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
|
|
23403
|
-
//把原始 width/height 乘这个比例,得到补偿后的尺寸。
|
|
23404
|
-
const compensatedWidth = width * fractionalZoomScale;
|
|
23405
|
-
const compensatedHeight = height * fractionalZoomScale;
|
|
23406
|
-
//尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
|
|
23407
|
-
const offsetAlongX = (compensatedWidth - width) / 2;
|
|
23408
|
-
const offsetAlongY = (compensatedHeight - height) / 2;
|
|
23409
|
-
//“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
|
|
23410
|
-
const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
|
|
23411
|
-
const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
|
|
23412
|
-
//“下方向”单位向量(从左上指向左下),同理用于旋转场景。
|
|
23413
|
-
const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
|
|
23414
|
-
const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 1;
|
|
23415
|
-
/**
|
|
23416
|
-
* 计算补偿后的新左上角:
|
|
23417
|
-
* 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
|
|
23418
|
-
* 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
|
|
23419
|
-
*/
|
|
23420
|
-
const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
|
|
23421
|
-
const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
|
|
23422
|
-
setMapImageFrame({
|
|
23423
|
-
url: staticMapUrl,
|
|
23424
|
-
x: compensatedTopLeftX,
|
|
23425
|
-
y: compensatedTopLeftY,
|
|
23426
|
-
width: compensatedWidth,
|
|
23427
|
-
height: compensatedHeight,
|
|
23428
|
-
transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
|
|
23429
|
-
});
|
|
23430
23624
|
}
|
|
23431
23625
|
else {
|
|
23432
23626
|
setMapImageFrame(null);
|
|
@@ -23446,6 +23640,8 @@ const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 1
|
|
|
23446
23640
|
size,
|
|
23447
23641
|
zoom,
|
|
23448
23642
|
googleMapStaticApiKey,
|
|
23643
|
+
googleMapStaticUrlSigningSecret,
|
|
23644
|
+
signGoogleStaticMapUrl$1,
|
|
23449
23645
|
staticMapRetryCount,
|
|
23450
23646
|
staticMapBlockedUntil,
|
|
23451
23647
|
]);
|
|
@@ -29584,7 +29780,7 @@ const defaultMapConfig$1 = DEFAULT_STYLES;
|
|
|
29584
29780
|
// 地图渲染器组件
|
|
29585
29781
|
const MowerMapRenderer = React.forwardRef(({ sn, mowerIconConfig = {}, platform = exports.PlatformType.WEB, mapType = exports.MapType.NORMAL, edger = false, unitType = UnitsType.Imperial, language = 'en', onlyRead = false, isHighlight = true, mapConfig,
|
|
29586
29782
|
// pathConfig,
|
|
29587
|
-
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, zIndex, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, googleMapStaticApiKey, onHandleEvent, onSelectElement, onH5FirstSelectObstaclePoint, }, ref) => {
|
|
29783
|
+
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, zIndex, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, googleMapStaticApiKey, googleMapStaticUrlSigningSecret, signGoogleStaticMapUrl, onHandleEvent, onSelectElement, onH5FirstSelectObstaclePoint, }, ref) => {
|
|
29588
29784
|
const [currentError, setCurrentError] = React.useState(null);
|
|
29589
29785
|
// const mapRef = useMap();
|
|
29590
29786
|
const [processStateIsMowing, setProcessStateIsMowing] = React.useState(false);
|
|
@@ -29830,6 +30026,8 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29830
30026
|
showStraddleBoundaryBorder,
|
|
29831
30027
|
overlayLayout,
|
|
29832
30028
|
googleMapStaticApiKey,
|
|
30029
|
+
googleMapStaticUrlSigningSecret,
|
|
30030
|
+
signGoogleStaticMapUrl,
|
|
29833
30031
|
onH5FirstSelectObstaclePoint,
|
|
29834
30032
|
};
|
|
29835
30033
|
}, [
|
|
@@ -29853,6 +30051,8 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29853
30051
|
showStraddleBoundaryBorder,
|
|
29854
30052
|
overlayLayout,
|
|
29855
30053
|
googleMapStaticApiKey,
|
|
30054
|
+
googleMapStaticUrlSigningSecret,
|
|
30055
|
+
signGoogleStaticMapUrl,
|
|
29856
30056
|
onH5FirstSelectObstaclePoint,
|
|
29857
30057
|
]);
|
|
29858
30058
|
/**
|
|
@@ -30328,3 +30528,5 @@ exports.initDoodle = initDoodle;
|
|
|
30328
30528
|
exports.initObstacle = initObstacle;
|
|
30329
30529
|
exports.initVisionOff = initVisionOff;
|
|
30330
30530
|
exports.restorePointsFormat = restorePointsFormat;
|
|
30531
|
+
exports.signGoogleStaticMapUrl = signGoogleStaticMapUrl;
|
|
30532
|
+
exports.signGoogleStaticMapUrlSync = signGoogleStaticMapUrlSync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAwBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AA0B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAMD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAwBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AA0B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAMD,eAAO,MAAM,gBAAgB,mGA20B5B,CAAC;AAIF,eAAe,gBAAgB,CAAC;AAChC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/render/svgElement/PolygonELement/components/Magnifier/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/render/svgElement/PolygonELement/components/Magnifier/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAkB5E,UAAU,SAAS;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE;QACR,UAAU,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,QAAQ,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACnC,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI,CAAC;IACT,QAAQ,EAAE,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC;CACrC;AAED,UAAU,cAAc;IACtB,cAAc;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW;IACX,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,WAAW;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuhBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/types/renderer.d.ts
CHANGED
|
@@ -193,6 +193,15 @@ export interface MowerMapRendererProps {
|
|
|
193
193
|
heightOptions?: number[];
|
|
194
194
|
globalHeight?: number;
|
|
195
195
|
googleMapStaticApiKey?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Maps Static API URL 签名密钥(Cloud Console 中的 URL signing secret)。
|
|
198
|
+
* 会随 H5 请求暴露在客户端,生产环境更推荐 signGoogleStaticMapUrl 走服务端签名。
|
|
199
|
+
*/
|
|
200
|
+
googleMapStaticUrlSigningSecret?: string;
|
|
201
|
+
/**
|
|
202
|
+
* 由宿主在服务端完成 Static Map URL 签名后返回完整 URL(推荐生产使用)
|
|
203
|
+
*/
|
|
204
|
+
signGoogleStaticMapUrl?: (unsignedUrl: string) => Promise<string> | string;
|
|
196
205
|
onHandleEvent?: (type: ClickEventType, data: any) => void;
|
|
197
206
|
onSelectElement?: (type: DataType) => void;
|
|
198
207
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/types/renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAC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CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,oBAAoB,CAAA;KAAE,CAAC;CACxF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Maps Static API 数字签名
|
|
3
|
+
* @see https://developers.google.com/maps/documentation/maps-static/digital-signature
|
|
4
|
+
*
|
|
5
|
+
* 使用纯 JS HMAC-SHA1,兼容 H5 WebView / 非 HTTPS 等无 crypto.subtle 的环境。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 对 Maps Static API 请求 URL 追加 `signature` 参数。
|
|
9
|
+
* 签名内容为 pathname + search(不含 scheme/host),算法 HMAC-SHA1 + URL-safe Base64。
|
|
10
|
+
*
|
|
11
|
+
* @param inputUrl 完整未签名 URL(须已包含 key 等 query 参数)
|
|
12
|
+
* @param urlSigningSecret Cloud Console「URL 签名密钥」(URL-safe Base64)
|
|
13
|
+
*/
|
|
14
|
+
export declare function signGoogleStaticMapUrlSync(inputUrl: string, urlSigningSecret: string): string;
|
|
15
|
+
/** 异步包装,便于与宿主 signGoogleStaticMapUrl 回调统一 Promise 接口 */
|
|
16
|
+
export declare function signGoogleStaticMapUrl(inputUrl: string, urlSigningSecret: string): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=googleStaticMapSign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"googleStaticMapSign.d.ts","sourceRoot":"","sources":["../../src/utils/googleStaticMapSign.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4JH;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAU7F;AAED,wDAAwD;AACxD,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|