@mapsindoors/react-native-maps-indoors-mapbox 2.8.1-rc.1 → 2.9.1
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 +118 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +10 -0
- package/android/src/main/java/com/mapsindoorsrn/core/BaseMapCacheProviders.java +94 -0
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +140 -49
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +16 -7
- package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +1 -1
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +115 -20
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +200 -11
- package/android/src/main/java/com/mapsindoorsrn/core/RnGson.java +110 -0
- package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +1 -1
- package/android/src/main/java/com/mapsindoorsrn/core/models/DirectionsRendererOptionsModel.java +498 -0
- package/index.ts +25 -0
- package/ios/.swift-format +79 -0
- package/ios/core/DirectionsRendererBridge.m +11 -0
- package/ios/core/DirectionsRendererModule.swift +352 -210
- package/ios/core/DirectionsRendererOptions.swift +352 -0
- package/ios/core/MapControlModule.swift +326 -244
- package/ios/core/MapsIndoorsBridge.m +14 -1
- package/ios/core/MapsIndoorsData.swift +1 -0
- package/ios/core/MapsIndoorsModule.swift +195 -33
- package/ios/core/Sources/MainThread/CallGeneration.swift +38 -0
- package/ios/core/Sources/MainThread/MainThread.swift +25 -0
- package/ios/core/UtilsModule.swift +57 -45
- package/package.json +5 -1
- package/react-native-maps-indoors-mapbox.podspec +6 -2
- package/specs/NativeDirectionsRendererModule.ts +3 -0
- package/specs/NativeMapsIndoorsModule.ts +6 -1
- package/src/core/EventNames.ts +3 -0
- package/src/core/MPCameraPosition.ts +1 -1
- package/src/core/MPDirectionsRenderer.ts +88 -3
- package/src/core/MPDirectionsRendererOptions.ts +287 -0
- package/src/core/MPError.ts +48 -1
- package/src/core/MPLanguageTag.ts +222 -0
- package/src/core/MPLegBoundaryIcons.ts +130 -0
- package/src/core/MPRouteAnimationType.ts +24 -0
- package/src/core/MPRouteArrowStyle.ts +28 -0
- package/src/core/MPRouteMarkerDisplayRule.ts +140 -0
- package/src/core/MPRouteStampType.ts +24 -0
- package/src/core/MPRouteStopIconConfig.ts +5 -3
- package/src/core/MPSolution.ts +33 -2
- package/src/core/MPStrokeStyle.ts +22 -0
- package/src/core/MapsIndoors.ts +155 -11
- package/src/core/OnBaseMapCacheProgressListener.ts +20 -0
- package/src/core/RouteStopIconConfig.ts +5 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalization and RFC 4647 lookup for BCP-47 language tags.
|
|
3
|
+
*
|
|
4
|
+
* Both native SDKs rewrite a language tag before it reaches the backend, but they do it in
|
|
5
|
+
* different places and with slightly different rules, so the same tag could be accepted on one
|
|
6
|
+
* platform and dropped on the other. This is a single TypeScript port of both, so that "is this
|
|
7
|
+
* tag supported" and "which tag should I actually pass" get the same answer on iOS and Android
|
|
8
|
+
* without a round trip to native.
|
|
9
|
+
*
|
|
10
|
+
* Ported from:
|
|
11
|
+
*
|
|
12
|
+
* * iOS `MapsIndoorsCore/util/LanguageCodeNormalizer.swift` - tag canonicalization.
|
|
13
|
+
* * Android `com.mapsindoors.core.MPLanguageManager` - `canonicalLanguage`, `buildPriorityList`
|
|
14
|
+
* and `rfc4647Lookup`.
|
|
15
|
+
*
|
|
16
|
+
* iOS's normalizer has four switch cases this port omits - `"hans-cn"`, `"hant-tw"`, `"hant-hk"`
|
|
17
|
+
* and `"hant-mo"`. They are unreachable there: the tag is split on `-` before the switch runs, so
|
|
18
|
+
* no subtag can contain one. Omitting them is not an incomplete port.
|
|
19
|
+
*
|
|
20
|
+
* Where the two natives disagree, the choice and the reason are documented at the point of
|
|
21
|
+
* divergence below. Deliberately dependency-free: this module imports nothing, so it can be unit
|
|
22
|
+
* tested without a React Native mock and cannot participate in the `index.ts` import cycle.
|
|
23
|
+
*
|
|
24
|
+
* @module MPLanguageTag
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The Chinese script implied by a region subtag.
|
|
29
|
+
*
|
|
30
|
+
* Mirrors Android's `MPLanguageManager.buildPriorityList`. iOS's normalizer omits `MY`; we follow
|
|
31
|
+
* Android, because CLDR's likely-subtags maps `zh-MY` to `zh-Hans` and Malaysian Chinese is
|
|
32
|
+
* written in Simplified. iOS's omission looks like an oversight rather than a decision - its
|
|
33
|
+
* `LanguageCodeNormalizerTests` never covers `zh-MY`, while Android's
|
|
34
|
+
* `buildPriorityListEnrichesZhMYWithHans` pins it explicitly.
|
|
35
|
+
*/
|
|
36
|
+
const CHINESE_REGION_SCRIPTS: Readonly<Record<string, "Hans" | "Hant">> = {
|
|
37
|
+
CN: "Hans",
|
|
38
|
+
SG: "Hans",
|
|
39
|
+
MY: "Hans",
|
|
40
|
+
TW: "Hant",
|
|
41
|
+
HK: "Hant",
|
|
42
|
+
MO: "Hant",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Script subtags recognized on a Chinese tag, keyed by their lower-case form. */
|
|
46
|
+
const CHINESE_SCRIPTS: Readonly<Record<string, "Hans" | "Hant">> = {
|
|
47
|
+
hans: "Hans",
|
|
48
|
+
hant: "Hant",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Splits a tag on either separator.
|
|
53
|
+
*
|
|
54
|
+
* BCP-47 uses `-`, but ICU and `java.util.Locale.toString()` use `_`, and JavaScript i18n
|
|
55
|
+
* libraries hand out both. iOS's normalizer accepts either; Android's does not, because
|
|
56
|
+
* `Locale.forLanguageTag("zh_Hans")` returns the undetermined locale. We follow iOS: accepting `_`
|
|
57
|
+
* is strictly more permissive, so it cannot turn a tag that works today into one that doesn't.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} tag
|
|
60
|
+
* @returns {string[]} The non-empty subtags, in order.
|
|
61
|
+
*/
|
|
62
|
+
function subtagsOf(tag: string): string[] {
|
|
63
|
+
return tag.split(/[-_]+/).filter((part) => part.length > 0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns the canonical BCP-47 form of a language tag, or the trimmed input unchanged when it is
|
|
68
|
+
* not a tag this function knows how to rewrite.
|
|
69
|
+
*
|
|
70
|
+
* * Chinese script and legacy region forms collapse onto the two tags the backend actually
|
|
71
|
+
* publishes, `zh-Hans` and `zh-Hant`. So `zh_hans`, `ZH-HANS`, `zh-CN`, `zh-SG` and `zh-MY` all
|
|
72
|
+
* become `zh-Hans`, and `zh-Hant`, `zh-TW`, `zh-HK` and `zh-MO` all become `zh-Hant`.
|
|
73
|
+
* * Bare `zh` is returned as `zh`, unresolved. There is no way to tell which script the caller
|
|
74
|
+
* wants, and guessing would silently serve Traditional content to a Simplified audience, or the
|
|
75
|
+
* reverse.
|
|
76
|
+
* * Everything else gets a generic rewrite - language lower-cased, four-character script subtag
|
|
77
|
+
* Title-cased, two- and three-character subtags upper-cased. So `EN` becomes `en`, `en_us`
|
|
78
|
+
* becomes `en-US`, `pt-br` becomes `pt-BR`, and `sr_latn_rs` becomes `sr-Latn-RS`.
|
|
79
|
+
* * Empty or whitespace-only input comes back as the empty string, so the caller can apply its own
|
|
80
|
+
* fallback.
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
* @param {?string} [tag] A language tag in any casing, with either `-` or `_` separators.
|
|
84
|
+
* @returns {string} The canonical form, or the trimmed input if it is not recognizable.
|
|
85
|
+
*/
|
|
86
|
+
export function normalizeLanguageTag(tag?: string | null): string {
|
|
87
|
+
const trimmed = tag?.trim() ?? "";
|
|
88
|
+
if (trimmed.length === 0) {
|
|
89
|
+
return trimmed;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const parts = subtagsOf(trimmed);
|
|
93
|
+
if (parts.length === 0) {
|
|
94
|
+
return trimmed;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const language = parts[0].toLowerCase();
|
|
98
|
+
const subtags = parts.slice(1);
|
|
99
|
+
|
|
100
|
+
if (language === "zh") {
|
|
101
|
+
// Script wins over region, and the first recognized subtag wins, so `zh-Hant-TW` resolves
|
|
102
|
+
// on `Hant` rather than on `TW`. The two agree here, but the order is what iOS does.
|
|
103
|
+
for (const subtag of subtags) {
|
|
104
|
+
const script = CHINESE_SCRIPTS[subtag.toLowerCase()] ?? CHINESE_REGION_SCRIPTS[subtag.toUpperCase()];
|
|
105
|
+
if (script !== undefined) {
|
|
106
|
+
return `zh-${script}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (subtags.length === 0) {
|
|
110
|
+
return "zh";
|
|
111
|
+
}
|
|
112
|
+
// An unrecognized subtag (`zh-Foo`) deliberately falls through to the generic rewrite
|
|
113
|
+
// rather than collapsing to bare `zh`, so the caller's information is not discarded.
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const rebuilt = [language];
|
|
117
|
+
for (const subtag of subtags) {
|
|
118
|
+
if (subtag.length === 4) {
|
|
119
|
+
rebuilt.push(subtag.charAt(0).toUpperCase() + subtag.slice(1).toLowerCase());
|
|
120
|
+
} else if (subtag.length === 2 || subtag.length === 3) {
|
|
121
|
+
// Upper-casing a three-character subtag is wrong for extlangs and variants (`zh-yue`
|
|
122
|
+
// becomes `zh-YUE`), but it is what the iOS SDK does, and matching it matters more
|
|
123
|
+
// than being right about a subtag the backend never publishes.
|
|
124
|
+
rebuilt.push(subtag.toUpperCase());
|
|
125
|
+
} else {
|
|
126
|
+
rebuilt.push(subtag);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return rebuilt.join("-");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Builds the RFC 4647 priority list for a tag.
|
|
134
|
+
*
|
|
135
|
+
* Port of Android's `MPLanguageManager.buildPriorityList`: a Chinese tag that carries a region but
|
|
136
|
+
* no script gets the implied script prepended, so `zh-CN` prefers a solution's `zh-Hans` over its
|
|
137
|
+
* bare `zh`. Anything else is a single-entry list and takes the plain right-to-left walk.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} tag
|
|
140
|
+
* @returns {string[]} The ranges to try, most preferred first.
|
|
141
|
+
*/
|
|
142
|
+
function buildPriorityList(tag: string): string[] {
|
|
143
|
+
const parts = subtagsOf(tag);
|
|
144
|
+
if (parts.length < 2 || parts[0].toLowerCase() !== "zh") {
|
|
145
|
+
return [tag];
|
|
146
|
+
}
|
|
147
|
+
// A four-character subtag is a script. Android skips enrichment when one is already present
|
|
148
|
+
// rather than second-guessing an explicit choice.
|
|
149
|
+
if (parts.slice(1).some((part) => part.length === 4)) {
|
|
150
|
+
return [tag];
|
|
151
|
+
}
|
|
152
|
+
const region = parts.slice(1).find((part) => part.length === 2);
|
|
153
|
+
const script = region !== undefined ? CHINESE_REGION_SCRIPTS[region.toUpperCase()] : undefined;
|
|
154
|
+
return script !== undefined ? [`zh-${script}`, tag] : [tag];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Resolves a language tag to the exact tag a solution advertises, or `undefined` when nothing in
|
|
159
|
+
* the fallback chain matches.
|
|
160
|
+
*
|
|
161
|
+
* Port of Android's `MPLanguageManager.canonicalLanguage`: an exact case-insensitive match first,
|
|
162
|
+
* then an RFC 4647 "lookup" walk that strips subtags right to left, with the Chinese
|
|
163
|
+
* region-to-script enrichment tried ahead of the raw tag. The canonical form from
|
|
164
|
+
* {@link normalizeLanguageTag} is tried first of all, which is what lets `zh_Hans` and `ZH-CN`
|
|
165
|
+
* resolve the same way they do on iOS.
|
|
166
|
+
*
|
|
167
|
+
* The return value is the entry as `available` spells it, not as the caller spelled it, so the
|
|
168
|
+
* language reaches the backend with the casing the CMS published - `zh-Hant`, not `zh-hant`.
|
|
169
|
+
*
|
|
170
|
+
* Conservative about ambiguity by design: bare `zh` against a solution advertising only `zh-Hans`
|
|
171
|
+
* and `zh-Hant` returns `undefined`. The iOS SDK's own `isLanguageAvailable` is looser and would
|
|
172
|
+
* accept it, but Android's `setLanguage` refuses, so a permissive answer here would be a lie on
|
|
173
|
+
* the platform that actually enforces it. A resolved tag is therefore safe to pass to
|
|
174
|
+
* `MapsIndoors.setLanguage` on both platforms; an unresolved one is not necessarily rejected.
|
|
175
|
+
*
|
|
176
|
+
* @export
|
|
177
|
+
* @param {?string} [tag] A language tag in any casing, with either `-` or `_` separators.
|
|
178
|
+
* @param {?string[]} [available] The solution's advertised tags - `MPSolution.availableLanguages`.
|
|
179
|
+
* @returns {(string | undefined)} The matching entry from `available`, or `undefined`.
|
|
180
|
+
*/
|
|
181
|
+
export function resolveLanguageTag(
|
|
182
|
+
tag?: string | null,
|
|
183
|
+
available?: readonly (string | undefined | null)[] | null,
|
|
184
|
+
): string | undefined {
|
|
185
|
+
const trimmed = tag?.trim() ?? "";
|
|
186
|
+
// Android's `canonicalLanguage` rejects anything shorter than two characters outright.
|
|
187
|
+
if (trimmed.length < 2 || available == null) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const candidates = available.filter((entry): entry is string => typeof entry === "string" && entry.length > 0);
|
|
192
|
+
if (candidates.length === 0) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const matches = (candidate: string): string | undefined =>
|
|
197
|
+
candidates.find((entry) => entry.toLowerCase() === candidate.toLowerCase());
|
|
198
|
+
|
|
199
|
+
const exact = matches(trimmed);
|
|
200
|
+
if (exact !== undefined) {
|
|
201
|
+
return exact;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Putting the canonical form first only ever *adds* a candidate - the raw priority list still
|
|
205
|
+
// follows - so this is never stricter than Android's own walk.
|
|
206
|
+
const ranges = [normalizeLanguageTag(trimmed), ...buildPriorityList(trimmed)];
|
|
207
|
+
for (const range of ranges) {
|
|
208
|
+
let candidate = range;
|
|
209
|
+
while (candidate.length > 0) {
|
|
210
|
+
const match = matches(candidate);
|
|
211
|
+
if (match !== undefined) {
|
|
212
|
+
return match;
|
|
213
|
+
}
|
|
214
|
+
const dash = candidate.lastIndexOf("-");
|
|
215
|
+
if (dash < 0) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
candidate = candidate.slice(0, dash);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom icons drawn where a route crosses a connector, selected by connector type.
|
|
3
|
+
*
|
|
4
|
+
* Assigned to {@link MPDirectionsRendererOptionsParams.legBoundaryIcons}.
|
|
5
|
+
*
|
|
6
|
+
* Each icon is a media library URL, which the SDK downloads and caches. Every property
|
|
7
|
+
* is optional and resolves on its own, so only the connector types set here are
|
|
8
|
+
* overridden, the rest keep the icon configured for the solution, or the built-in glyph.
|
|
9
|
+
* A connector without its own icon falls back to {@link defaultIcon}.
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @class MPLegBoundaryIcons
|
|
13
|
+
* @typedef {MPLegBoundaryIcons}
|
|
14
|
+
*/
|
|
15
|
+
export default class MPLegBoundaryIcons {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of MPLegBoundaryIcons.
|
|
19
|
+
*
|
|
20
|
+
* @constructor
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
private constructor(
|
|
24
|
+
public readonly defaultIcon?: string,
|
|
25
|
+
public readonly elevator?: string,
|
|
26
|
+
public readonly escalator?: string,
|
|
27
|
+
public readonly stairs?: string,
|
|
28
|
+
public readonly ramp?: string,
|
|
29
|
+
public readonly wheelchairRamp?: string,
|
|
30
|
+
public readonly wheelchairLift?: string,
|
|
31
|
+
public readonly ladder?: string,
|
|
32
|
+
public readonly entry?: string,
|
|
33
|
+
public readonly scale?: number,
|
|
34
|
+
) { }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creator for MPLegBoundaryIcons.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
* @static
|
|
41
|
+
* @param {MPLegBoundaryIconsParams} object
|
|
42
|
+
* @returns {MPLegBoundaryIcons}
|
|
43
|
+
*/
|
|
44
|
+
public static create(object: MPLegBoundaryIconsParams): MPLegBoundaryIcons {
|
|
45
|
+
return new MPLegBoundaryIcons(
|
|
46
|
+
object?.defaultIcon,
|
|
47
|
+
object?.elevator,
|
|
48
|
+
object?.escalator,
|
|
49
|
+
object?.stairs,
|
|
50
|
+
object?.ramp,
|
|
51
|
+
object?.wheelchairRamp,
|
|
52
|
+
object?.wheelchairLift,
|
|
53
|
+
object?.ladder,
|
|
54
|
+
object?.entry,
|
|
55
|
+
object?.scale,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Parameter interface for {@link MPLegBoundaryIcons}.
|
|
62
|
+
*
|
|
63
|
+
* Every icon is a media library URL.
|
|
64
|
+
*
|
|
65
|
+
* @export
|
|
66
|
+
* @interface MPLegBoundaryIconsParams
|
|
67
|
+
* @typedef {MPLegBoundaryIconsParams}
|
|
68
|
+
*/
|
|
69
|
+
export interface MPLegBoundaryIconsParams {
|
|
70
|
+
/**
|
|
71
|
+
* Fallback icon for any connector type without its own icon.
|
|
72
|
+
*
|
|
73
|
+
* @type {?string}
|
|
74
|
+
*/
|
|
75
|
+
defaultIcon?: string,
|
|
76
|
+
/**
|
|
77
|
+
* Icon for elevator floor changes.
|
|
78
|
+
*
|
|
79
|
+
* @type {?string}
|
|
80
|
+
*/
|
|
81
|
+
elevator?: string,
|
|
82
|
+
/**
|
|
83
|
+
* Icon for escalator floor changes.
|
|
84
|
+
*
|
|
85
|
+
* @type {?string}
|
|
86
|
+
*/
|
|
87
|
+
escalator?: string,
|
|
88
|
+
/**
|
|
89
|
+
* Icon for stairs floor changes.
|
|
90
|
+
*
|
|
91
|
+
* @type {?string}
|
|
92
|
+
*/
|
|
93
|
+
stairs?: string,
|
|
94
|
+
/**
|
|
95
|
+
* Icon for ramp floor changes.
|
|
96
|
+
*
|
|
97
|
+
* @type {?string}
|
|
98
|
+
*/
|
|
99
|
+
ramp?: string,
|
|
100
|
+
/**
|
|
101
|
+
* Icon for wheelchair ramp floor changes.
|
|
102
|
+
*
|
|
103
|
+
* @type {?string}
|
|
104
|
+
*/
|
|
105
|
+
wheelchairRamp?: string,
|
|
106
|
+
/**
|
|
107
|
+
* Icon for wheelchair lift floor changes.
|
|
108
|
+
*
|
|
109
|
+
* @type {?string}
|
|
110
|
+
*/
|
|
111
|
+
wheelchairLift?: string,
|
|
112
|
+
/**
|
|
113
|
+
* Icon for ladder floor changes.
|
|
114
|
+
*
|
|
115
|
+
* @type {?string}
|
|
116
|
+
*/
|
|
117
|
+
ladder?: string,
|
|
118
|
+
/**
|
|
119
|
+
* Icon for building entrances, where the route crosses an external door.
|
|
120
|
+
*
|
|
121
|
+
* @type {?string}
|
|
122
|
+
*/
|
|
123
|
+
entry?: string,
|
|
124
|
+
/**
|
|
125
|
+
* Scale multiplier applied to every connector icon, where 1.0 is the intrinsic size.
|
|
126
|
+
*
|
|
127
|
+
* @type {?number}
|
|
128
|
+
*/
|
|
129
|
+
scale?: number,
|
|
130
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The animation applied to the overlay travelling along the route polyline.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
7
|
+
export enum MPRouteAnimationType {
|
|
8
|
+
/**
|
|
9
|
+
* No travelling animation, only the static styled route line is drawn.
|
|
10
|
+
*/
|
|
11
|
+
none = "none",
|
|
12
|
+
/**
|
|
13
|
+
* The overlay is revealed progressively along the route, then repeats.
|
|
14
|
+
*/
|
|
15
|
+
flow = "flow",
|
|
16
|
+
/**
|
|
17
|
+
* The overlay blinks in place, oscillating its opacity.
|
|
18
|
+
*/
|
|
19
|
+
pulse = "pulse",
|
|
20
|
+
/**
|
|
21
|
+
* A short bright segment travels along the route, then repeats.
|
|
22
|
+
*/
|
|
23
|
+
comet = "comet",
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in arrow shape drawn when the stamp type is {@link MPRouteStampType.arrow}.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
7
|
+
export enum MPRouteArrowStyle {
|
|
8
|
+
/**
|
|
9
|
+
* A single chevron pointing along the route.
|
|
10
|
+
*/
|
|
11
|
+
chevron = "chevron",
|
|
12
|
+
/**
|
|
13
|
+
* Two stacked chevrons pointing along the route.
|
|
14
|
+
*/
|
|
15
|
+
chevronDouble = "chevronDouble",
|
|
16
|
+
/**
|
|
17
|
+
* A solid triangle pointing along the route.
|
|
18
|
+
*/
|
|
19
|
+
triangle = "triangle",
|
|
20
|
+
/**
|
|
21
|
+
* A shaft with an arrowhead, pointing along the route.
|
|
22
|
+
*/
|
|
23
|
+
arrow = "arrow",
|
|
24
|
+
/**
|
|
25
|
+
* A solid navigation dart pointing along the route.
|
|
26
|
+
*/
|
|
27
|
+
dart = "dart",
|
|
28
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import MPSize from "./MPSize";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Styling for the origin (start) or destination (end) marker of a rendered route.
|
|
5
|
+
*
|
|
6
|
+
* Assigned to {@link MPDirectionsRendererOptionsParams.startDisplayRule} or
|
|
7
|
+
* {@link MPDirectionsRendererOptionsParams.endDisplayRule}.
|
|
8
|
+
*
|
|
9
|
+
* Every property is optional, an omitted property is inherited from the solution
|
|
10
|
+
* configuration, or from the built-in default. There is no built-in icon, so a
|
|
11
|
+
* terminus marker is only drawn when an {@link iconUrl} is configured.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @class MPRouteMarkerDisplayRule
|
|
15
|
+
* @typedef {MPRouteMarkerDisplayRule}
|
|
16
|
+
*/
|
|
17
|
+
export default class MPRouteMarkerDisplayRule {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instance of MPRouteMarkerDisplayRule.
|
|
21
|
+
*
|
|
22
|
+
* @constructor
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private constructor(
|
|
26
|
+
public readonly iconUrl?: string,
|
|
27
|
+
public readonly iconVisible?: boolean,
|
|
28
|
+
public readonly iconSize?: MPSize,
|
|
29
|
+
public readonly label?: string,
|
|
30
|
+
public readonly labelVisible?: boolean,
|
|
31
|
+
public readonly labelTextSize?: number,
|
|
32
|
+
public readonly labelTextColor?: string,
|
|
33
|
+
public readonly labelHaloColor?: string,
|
|
34
|
+
public readonly labelHaloWidth?: number,
|
|
35
|
+
public readonly zoomFrom?: number,
|
|
36
|
+
public readonly zoomTo?: number,
|
|
37
|
+
) { }
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creator for MPRouteMarkerDisplayRule.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @static
|
|
44
|
+
* @param {MPRouteMarkerDisplayRuleParams} object
|
|
45
|
+
* @returns {MPRouteMarkerDisplayRule}
|
|
46
|
+
*/
|
|
47
|
+
public static create(object: MPRouteMarkerDisplayRuleParams): MPRouteMarkerDisplayRule {
|
|
48
|
+
return new MPRouteMarkerDisplayRule(
|
|
49
|
+
object?.iconUrl,
|
|
50
|
+
object?.iconVisible,
|
|
51
|
+
object?.iconSize,
|
|
52
|
+
object?.label,
|
|
53
|
+
object?.labelVisible,
|
|
54
|
+
object?.labelTextSize,
|
|
55
|
+
object?.labelTextColor,
|
|
56
|
+
object?.labelHaloColor,
|
|
57
|
+
object?.labelHaloWidth,
|
|
58
|
+
object?.zoomFrom,
|
|
59
|
+
object?.zoomTo,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parameter interface for {@link MPRouteMarkerDisplayRule}.
|
|
66
|
+
*
|
|
67
|
+
* @export
|
|
68
|
+
* @interface MPRouteMarkerDisplayRuleParams
|
|
69
|
+
* @typedef {MPRouteMarkerDisplayRuleParams}
|
|
70
|
+
*/
|
|
71
|
+
export interface MPRouteMarkerDisplayRuleParams {
|
|
72
|
+
/**
|
|
73
|
+
* Media library URL of the marker icon, which the SDK downloads and caches.
|
|
74
|
+
*
|
|
75
|
+
* @type {?string}
|
|
76
|
+
*/
|
|
77
|
+
iconUrl?: string,
|
|
78
|
+
/**
|
|
79
|
+
* Whether the icon is shown. Shown by default when an {@link iconUrl} is set.
|
|
80
|
+
*
|
|
81
|
+
* @type {?boolean}
|
|
82
|
+
*/
|
|
83
|
+
iconVisible?: boolean,
|
|
84
|
+
/**
|
|
85
|
+
* The on screen size of the icon, in density independent units - points on iOS, dp on
|
|
86
|
+
* Android. Not raw pixels: the SDKs scale by the screen's density, so the same value is the
|
|
87
|
+
* same physical size on a 2x or 3x screen. Defaults to the icon's intrinsic size.
|
|
88
|
+
*
|
|
89
|
+
* @type {?MPSize}
|
|
90
|
+
*/
|
|
91
|
+
iconSize?: MPSize,
|
|
92
|
+
/**
|
|
93
|
+
* The text drawn with the marker.
|
|
94
|
+
*
|
|
95
|
+
* @type {?string}
|
|
96
|
+
*/
|
|
97
|
+
label?: string,
|
|
98
|
+
/**
|
|
99
|
+
* Whether the label is shown. Shown by default when a {@link label} is set.
|
|
100
|
+
*
|
|
101
|
+
* @type {?boolean}
|
|
102
|
+
*/
|
|
103
|
+
labelVisible?: boolean,
|
|
104
|
+
/**
|
|
105
|
+
* The label's text size, in density independent units - points on iOS, dp on Android.
|
|
106
|
+
*
|
|
107
|
+
* @type {?number}
|
|
108
|
+
*/
|
|
109
|
+
labelTextSize?: number,
|
|
110
|
+
/**
|
|
111
|
+
* The label's text color, given as a hex string (e.g. "#3071D9").
|
|
112
|
+
*
|
|
113
|
+
* @type {?string}
|
|
114
|
+
*/
|
|
115
|
+
labelTextColor?: string,
|
|
116
|
+
/**
|
|
117
|
+
* The label's halo (outline) color, given as a hex string (e.g. "#FFFFFF").
|
|
118
|
+
*
|
|
119
|
+
* @type {?string}
|
|
120
|
+
*/
|
|
121
|
+
labelHaloColor?: string,
|
|
122
|
+
/**
|
|
123
|
+
* The label's halo (outline) width, in density independent units - points on iOS, dp on Android.
|
|
124
|
+
*
|
|
125
|
+
* @type {?number}
|
|
126
|
+
*/
|
|
127
|
+
labelHaloWidth?: number,
|
|
128
|
+
/**
|
|
129
|
+
* The lowest zoom level at which the marker is shown.
|
|
130
|
+
*
|
|
131
|
+
* @type {?number}
|
|
132
|
+
*/
|
|
133
|
+
zoomFrom?: number,
|
|
134
|
+
/**
|
|
135
|
+
* The highest zoom level at which the marker is shown.
|
|
136
|
+
*
|
|
137
|
+
* @type {?number}
|
|
138
|
+
*/
|
|
139
|
+
zoomTo?: number,
|
|
140
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The repeating marker drawn along the route polyline.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
7
|
+
export enum MPRouteStampType {
|
|
8
|
+
/**
|
|
9
|
+
* No stamp, only the route line and any animation is drawn.
|
|
10
|
+
*/
|
|
11
|
+
none = "none",
|
|
12
|
+
/**
|
|
13
|
+
* A built-in direction indicating arrow, repeated along the line.
|
|
14
|
+
*
|
|
15
|
+
* The shape is chosen with {@link MPRouteArrowStyle}.
|
|
16
|
+
*/
|
|
17
|
+
arrow = "arrow",
|
|
18
|
+
/**
|
|
19
|
+
* A custom icon, repeated along the line.
|
|
20
|
+
*
|
|
21
|
+
* The icon is set with {@link MPDirectionsRendererOptionsParams.stampImageUrl}.
|
|
22
|
+
*/
|
|
23
|
+
custom = "custom",
|
|
24
|
+
}
|
|
@@ -30,10 +30,12 @@ export default class MPRouteStopIconConfig implements RouteStopIconConfig{
|
|
|
30
30
|
/**
|
|
31
31
|
* Internal
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* Not a URL: wrapping JSON in one throws on spec-compliant URL implementations (Expo 55+).
|
|
34
|
+
*
|
|
35
|
+
* @returns {string}
|
|
34
36
|
*/
|
|
35
|
-
getImage():
|
|
36
|
-
return
|
|
37
|
+
getImage(): string {
|
|
38
|
+
return JSON.stringify(this);
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/**
|
package/src/core/MPSolution.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MPSolutionConfig } from "../../index";
|
|
2
|
+
import { resolveLanguageTag } from "./MPLanguageTag";
|
|
2
3
|
import MPPOIType from "./MPPOIType";
|
|
3
4
|
import MPUtils from "./MPUtils";
|
|
4
5
|
|
|
@@ -66,12 +67,42 @@ export default class MPSolution {
|
|
|
66
67
|
/**
|
|
67
68
|
* Check if the solution supports a language.
|
|
68
69
|
*
|
|
70
|
+
* Matching follows BCP-47 / RFC 4647 rather than string equality, so the tag does not have to
|
|
71
|
+
* be spelled exactly the way the CMS spells it. Casing is ignored (`zh-hant` matches
|
|
72
|
+
* `zh-Hant`), the ICU underscore form is accepted (`zh_Hans`), legacy region-only Chinese tags
|
|
73
|
+
* resolve to their script (`zh-CN` matches `zh-Hans`, `zh-TW` matches `zh-Hant`), and a more
|
|
74
|
+
* specific tag falls back to a less specific one (`en-US` matches `en`).
|
|
75
|
+
*
|
|
76
|
+
* Deliberately conservative about ambiguity: bare `zh` does **not** match a solution that
|
|
77
|
+
* advertises only `zh-Hans` and `zh-Hant`, because there is no way to tell which script is
|
|
78
|
+
* wanted. Pass the script explicitly in that case.
|
|
79
|
+
*
|
|
80
|
+
* `true` means the tag is safe to pass to {@link MapsIndoors.setLanguage}. `false` is not a
|
|
81
|
+
* guarantee that `setLanguage` will reject it - see that method for what its boolean means on
|
|
82
|
+
* each platform.
|
|
83
|
+
*
|
|
69
84
|
* @public
|
|
70
|
-
* @param {?string} [language]
|
|
85
|
+
* @param {?string} [language] A BCP-47 language tag, for example `en`, `zh-Hans` or `zh-CN`.
|
|
71
86
|
* @returns {boolean}
|
|
72
87
|
*/
|
|
73
88
|
public hasLanguage(language?: string): boolean {
|
|
74
|
-
return
|
|
89
|
+
return this.resolveLanguage(language) !== undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Resolve a language tag to the exact tag this solution advertises.
|
|
94
|
+
*
|
|
95
|
+
* The companion to {@link hasLanguage}, for when a yes or no is not enough: given a device
|
|
96
|
+
* locale, this returns the tag to hand to {@link MapsIndoors.setLanguage}, spelled the way the
|
|
97
|
+
* CMS spells it. `resolveLanguage("zh-Hant-TW")` returns `"zh-Hant"` for a solution that
|
|
98
|
+
* publishes it.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
* @param {?string} [language] A BCP-47 language tag, for example `en`, `zh-Hans` or `zh-CN`.
|
|
102
|
+
* @returns {(string | undefined)} The matching advertised tag, or undefined if there is none.
|
|
103
|
+
*/
|
|
104
|
+
public resolveLanguage(language?: string): string | undefined {
|
|
105
|
+
return resolveLanguageTag(language, this.availableLanguages);
|
|
75
106
|
}
|
|
76
107
|
|
|
77
108
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the route polyline is drawn.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {string}
|
|
6
|
+
*/
|
|
7
|
+
export enum MPStrokeStyle {
|
|
8
|
+
/**
|
|
9
|
+
* A continuous line. Supported by all map providers.
|
|
10
|
+
*/
|
|
11
|
+
solid = "solid",
|
|
12
|
+
/**
|
|
13
|
+
* A dashed line.
|
|
14
|
+
*
|
|
15
|
+
* Not supported by Google Maps on iOS, where it falls back to {@link MPStrokeStyle.solid}.
|
|
16
|
+
*/
|
|
17
|
+
dashed = "dashed",
|
|
18
|
+
/**
|
|
19
|
+
* A dotted line. Supported by all map providers.
|
|
20
|
+
*/
|
|
21
|
+
dotted = "dotted",
|
|
22
|
+
}
|