@rnmapbox/maps 10.0.0-beta.58 → 10.0.0-beta.60
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/android/rctmgl/build.gradle +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +5 -96
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.kt +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.kt +125 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RCTMGLNativeUserLocation.kt +6 -10
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RenderMode.kt +21 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +36 -72
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +10 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +26 -5
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +2 -7
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/LocationEvent.kt +75 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/location/LocationManager.kt +66 -12
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLLocationModule.kt +147 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/extensions/CoordinateBounds.kt +3 -9
- package/ios/RCTMGL/RCTMGLLocation.m +1 -1
- package/ios/RCTMGL-v10/RCTMGLBackgroundLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLCircleLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLFillExtrustionLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLFillLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLHeatmapLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLLayer.swift +0 -2
- package/ios/RCTMGL-v10/RCTMGLLineLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +1 -1
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +10 -2
- package/ios/RCTMGL-v10/RCTMGLRasterLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLSkyLayer.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLStyle.swift +25 -15
- package/ios/RCTMGL-v10/RCTMGLSymbolLayer.swift +3 -1
- package/{assets → javascript/assets}/heading.png +0 -0
- package/{assets → javascript/assets}/heading@2x.png +0 -0
- package/{assets → javascript/assets}/heading@3x.png +0 -0
- package/javascript/components/Camera.tsx +1 -1
- package/javascript/components/HeadingIndicator.tsx +1 -1
- package/lib/commonjs/assets/heading.png +0 -0
- package/lib/commonjs/assets/heading@2x.png +0 -0
- package/lib/commonjs/assets/heading@3x.png +0 -0
- package/lib/commonjs/classes/AnimatedExtractCoordinateFromArray.js +3 -1
- package/lib/commonjs/classes/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/commonjs/components/AbstractLayer.js +3 -1
- package/lib/commonjs/components/AbstractLayer.js.map +1 -1
- package/lib/commonjs/components/AbstractSource.js +3 -1
- package/lib/commonjs/components/AbstractSource.js.map +1 -1
- package/lib/commonjs/components/BackgroundLayer.js +3 -1
- package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
- package/lib/commonjs/components/Callout.js +3 -1
- package/lib/commonjs/components/Callout.js.map +1 -1
- package/lib/commonjs/components/Camera.js.map +1 -1
- package/lib/commonjs/components/CircleLayer.js +3 -1
- package/lib/commonjs/components/CircleLayer.js.map +1 -1
- package/lib/commonjs/components/FillExtrusionLayer.js +3 -1
- package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
- package/lib/commonjs/components/FillLayer.js +3 -1
- package/lib/commonjs/components/FillLayer.js.map +1 -1
- package/lib/commonjs/components/HeadingIndicator.js +1 -1
- package/lib/commonjs/components/HeatmapLayer.js +3 -1
- package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
- package/lib/commonjs/components/ImageSource.js +3 -1
- package/lib/commonjs/components/ImageSource.js.map +1 -1
- package/lib/commonjs/components/Images.js +3 -1
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/Light.js +3 -1
- package/lib/commonjs/components/Light.js.map +1 -1
- package/lib/commonjs/components/LineLayer.js +3 -1
- package/lib/commonjs/components/LineLayer.js.map +1 -1
- package/lib/commonjs/components/MapView.js +3 -1
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/components/MarkerView.js +3 -1
- package/lib/commonjs/components/MarkerView.js.map +1 -1
- package/lib/commonjs/components/NativeBridgeComponent.js +3 -1
- package/lib/commonjs/components/NativeBridgeComponent.js.map +1 -1
- package/lib/commonjs/components/NativeUserLocation.js +3 -1
- package/lib/commonjs/components/NativeUserLocation.js.map +1 -1
- package/lib/commonjs/components/PointAnnotation.js +3 -1
- package/lib/commonjs/components/PointAnnotation.js.map +1 -1
- package/lib/commonjs/components/RasterDemSource.js +3 -1
- package/lib/commonjs/components/RasterDemSource.js.map +1 -1
- package/lib/commonjs/components/RasterLayer.js +3 -1
- package/lib/commonjs/components/RasterLayer.js.map +1 -1
- package/lib/commonjs/components/RasterSource.js +3 -1
- package/lib/commonjs/components/RasterSource.js.map +1 -1
- package/lib/commonjs/components/ShapeSource.js +3 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/SkyLayer.js +3 -1
- package/lib/commonjs/components/SkyLayer.js.map +1 -1
- package/lib/commonjs/components/SymbolLayer.js +3 -1
- package/lib/commonjs/components/SymbolLayer.js.map +1 -1
- package/lib/commonjs/components/UserLocation.js +3 -1
- package/lib/commonjs/components/UserLocation.js.map +1 -1
- package/lib/commonjs/components/VectorSource.js +3 -1
- package/lib/commonjs/components/VectorSource.js.map +1 -1
- package/lib/commonjs/components/annotations/Annotation.js +3 -1
- package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
- package/lib/commonjs/utils/BridgeValue.js +3 -1
- package/lib/commonjs/utils/BridgeValue.js.map +1 -1
- package/lib/commonjs/utils/Logger.js +3 -1
- package/lib/commonjs/utils/Logger.js.map +1 -1
- package/lib/commonjs/web/components/Camera.js +3 -1
- package/lib/commonjs/web/components/Camera.js.map +1 -1
- package/lib/commonjs/web/components/MapView.js +3 -1
- package/lib/commonjs/web/components/MapView.js.map +1 -1
- package/lib/commonjs/web/utils/Logger.js +3 -1
- package/lib/commonjs/web/utils/Logger.js.map +1 -1
- package/lib/module/assets/heading.png +0 -0
- package/lib/module/assets/heading@2x.png +0 -0
- package/lib/module/assets/heading@3x.png +0 -0
- package/lib/module/classes/AnimatedExtractCoordinateFromArray.js +3 -1
- package/lib/module/classes/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/module/components/AbstractLayer.js +3 -1
- package/lib/module/components/AbstractLayer.js.map +1 -1
- package/lib/module/components/AbstractSource.js +3 -1
- package/lib/module/components/AbstractSource.js.map +1 -1
- package/lib/module/components/BackgroundLayer.js +3 -1
- package/lib/module/components/BackgroundLayer.js.map +1 -1
- package/lib/module/components/Callout.js +3 -1
- package/lib/module/components/Callout.js.map +1 -1
- package/lib/module/components/Camera.js.map +1 -1
- package/lib/module/components/CircleLayer.js +3 -1
- package/lib/module/components/CircleLayer.js.map +1 -1
- package/lib/module/components/FillExtrusionLayer.js +3 -1
- package/lib/module/components/FillExtrusionLayer.js.map +1 -1
- package/lib/module/components/FillLayer.js +3 -1
- package/lib/module/components/FillLayer.js.map +1 -1
- package/lib/module/components/HeadingIndicator.js +1 -1
- package/lib/module/components/HeadingIndicator.js.map +1 -1
- package/lib/module/components/HeatmapLayer.js +3 -1
- package/lib/module/components/HeatmapLayer.js.map +1 -1
- package/lib/module/components/ImageSource.js +3 -1
- package/lib/module/components/ImageSource.js.map +1 -1
- package/lib/module/components/Images.js +3 -1
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/Light.js +3 -1
- package/lib/module/components/Light.js.map +1 -1
- package/lib/module/components/LineLayer.js +3 -1
- package/lib/module/components/LineLayer.js.map +1 -1
- package/lib/module/components/MapView.js +3 -1
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/MarkerView.js +3 -1
- package/lib/module/components/MarkerView.js.map +1 -1
- package/lib/module/components/NativeBridgeComponent.js +3 -1
- package/lib/module/components/NativeBridgeComponent.js.map +1 -1
- package/lib/module/components/NativeUserLocation.js +3 -1
- package/lib/module/components/NativeUserLocation.js.map +1 -1
- package/lib/module/components/PointAnnotation.js +3 -1
- package/lib/module/components/PointAnnotation.js.map +1 -1
- package/lib/module/components/RasterDemSource.js +3 -1
- package/lib/module/components/RasterDemSource.js.map +1 -1
- package/lib/module/components/RasterLayer.js +3 -1
- package/lib/module/components/RasterLayer.js.map +1 -1
- package/lib/module/components/RasterSource.js +3 -1
- package/lib/module/components/RasterSource.js.map +1 -1
- package/lib/module/components/ShapeSource.js +3 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/SkyLayer.js +3 -1
- package/lib/module/components/SkyLayer.js.map +1 -1
- package/lib/module/components/SymbolLayer.js +3 -1
- package/lib/module/components/SymbolLayer.js.map +1 -1
- package/lib/module/components/UserLocation.js +3 -1
- package/lib/module/components/UserLocation.js.map +1 -1
- package/lib/module/components/VectorSource.js +3 -1
- package/lib/module/components/VectorSource.js.map +1 -1
- package/lib/module/components/annotations/Annotation.js +3 -1
- package/lib/module/components/annotations/Annotation.js.map +1 -1
- package/lib/module/utils/BridgeValue.js +3 -1
- package/lib/module/utils/BridgeValue.js.map +1 -1
- package/lib/module/utils/Logger.js +3 -1
- package/lib/module/utils/Logger.js.map +1 -1
- package/lib/module/web/components/Camera.js +3 -1
- package/lib/module/web/components/Camera.js.map +1 -1
- package/lib/module/web/components/MapView.js +3 -1
- package/lib/module/web/components/MapView.js.map +1 -1
- package/lib/module/web/utils/Logger.js +3 -1
- package/lib/module/web/utils/Logger.js.map +1 -1
- package/lib/typescript/components/Camera.d.ts +1 -1
- package/lib/typescript/components/Camera.d.ts.map +1 -1
- package/package.json +6 -5
- package/plugin/build/generateCode.d.ts +42 -0
- package/plugin/build/generateCode.js +107 -0
- package/plugin/build/withMapbox.d.ts +1 -1
- package/plugin/build/withMapbox.js +3 -3
- package/plugin/src/generateCode.ts +155 -0
- package/plugin/src/withMapbox.ts +3 -5
- package/rnmapbox-maps.podspec +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.java +0 -215
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RenderMode.java +0 -42
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/LocationEvent.java +0 -100
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLLocationModule.java +0 -160
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Taken from @expo/config-plugins
|
|
4
|
+
*
|
|
5
|
+
* Sourcecode: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/src/utils/generateCode.ts
|
|
6
|
+
* LICENSE: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createHash = exports.createGeneratedHeaderComment = exports.removeGeneratedContents = exports.removeContents = exports.mergeContents = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Get line indexes for the generated section of a file.
|
|
15
|
+
*
|
|
16
|
+
* @param src
|
|
17
|
+
*/
|
|
18
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
19
|
+
function getGeneratedSectionIndexes(src, tag) {
|
|
20
|
+
const contents = src.split('\n');
|
|
21
|
+
const start = contents.findIndex((line) => line.includes(`@generated begin ${tag}`));
|
|
22
|
+
const end = contents.findIndex((line) => line.includes(`@generated end ${tag}`));
|
|
23
|
+
return { contents, start, end };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Merge the contents of two files together and add a generated header.
|
|
27
|
+
*
|
|
28
|
+
* @param src contents of the original file
|
|
29
|
+
* @param newSrc new contents to merge into the original file
|
|
30
|
+
* @param identifier used to update and remove merges
|
|
31
|
+
* @param anchor regex to where the merge should begin
|
|
32
|
+
* @param offset line offset to start merging at (<1 for behind the anchor)
|
|
33
|
+
* @param comment comment style `//` or `#`
|
|
34
|
+
*/
|
|
35
|
+
function mergeContents({ src, newSrc, tag, anchor, offset, comment, }) {
|
|
36
|
+
const header = createGeneratedHeaderComment(newSrc, tag, comment);
|
|
37
|
+
if (!src.includes(header)) {
|
|
38
|
+
// Ensure the old generated contents are removed.
|
|
39
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
40
|
+
return {
|
|
41
|
+
contents: addLines(sanitizedTarget ?? src, anchor, offset, [
|
|
42
|
+
header,
|
|
43
|
+
...newSrc.split('\n'),
|
|
44
|
+
`${comment} @generated end ${tag}`,
|
|
45
|
+
]),
|
|
46
|
+
didMerge: true,
|
|
47
|
+
didClear: !!sanitizedTarget,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { contents: src, didClear: false, didMerge: false };
|
|
51
|
+
}
|
|
52
|
+
exports.mergeContents = mergeContents;
|
|
53
|
+
function removeContents({ src, tag, }) {
|
|
54
|
+
// Ensure the old generated contents are removed.
|
|
55
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
56
|
+
return {
|
|
57
|
+
contents: sanitizedTarget ?? src,
|
|
58
|
+
didMerge: false,
|
|
59
|
+
didClear: !!sanitizedTarget,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.removeContents = removeContents;
|
|
63
|
+
function addLines(content, find, offset, toAdd) {
|
|
64
|
+
const lines = content.split('\n');
|
|
65
|
+
let lineIndex = lines.findIndex((line) => line.match(find));
|
|
66
|
+
if (lineIndex < 0) {
|
|
67
|
+
const error = new Error(`Failed to match "${find}" in contents:\n${content}`);
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
error.code = 'ERR_NO_MATCH';
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
for (const newLine of toAdd) {
|
|
74
|
+
lines.splice(lineIndex + offset, 0, newLine);
|
|
75
|
+
lineIndex++;
|
|
76
|
+
}
|
|
77
|
+
return lines.join('\n');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the generated section from a file, returns null when nothing can be removed.
|
|
81
|
+
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
|
|
82
|
+
*
|
|
83
|
+
* @param src
|
|
84
|
+
*/
|
|
85
|
+
function removeGeneratedContents(src, tag) {
|
|
86
|
+
const { contents, start, end } = getGeneratedSectionIndexes(src, tag);
|
|
87
|
+
if (start > -1 && end > -1 && start < end) {
|
|
88
|
+
contents.splice(start, end - start + 1);
|
|
89
|
+
// TODO: We could in theory check that the contents we're removing match the hash used in the header,
|
|
90
|
+
// this would ensure that we don't accidentally remove lines that someone added or removed from the generated section.
|
|
91
|
+
return contents.join('\n');
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
exports.removeGeneratedContents = removeGeneratedContents;
|
|
96
|
+
function createGeneratedHeaderComment(contents, tag, comment) {
|
|
97
|
+
const hashKey = createHash(contents);
|
|
98
|
+
// Everything after the `${tag} ` is unversioned and can be freely modified without breaking changes.
|
|
99
|
+
return `${comment} @generated begin ${tag} - expo prebuild (DO NOT MODIFY) ${hashKey}`;
|
|
100
|
+
}
|
|
101
|
+
exports.createGeneratedHeaderComment = createGeneratedHeaderComment;
|
|
102
|
+
function createHash(src) {
|
|
103
|
+
// this doesn't need to be secure, the shorter the better.
|
|
104
|
+
const hash = crypto_1.default.createHash('sha1').update(src).digest('hex');
|
|
105
|
+
return `sync-${hash}`;
|
|
106
|
+
}
|
|
107
|
+
exports.createHash = createHash;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports._addMapboxMavenRepo = exports.setExcludedArchitectures = exports.addMapboxInstallerBlock = exports.addInstallerBlock = exports.addConstantBlock = exports.applyCocoaPodsModifications = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const config_plugins_1 = require("
|
|
10
|
-
const generateCode_1 = require("
|
|
9
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
10
|
+
const generateCode_1 = require("./generateCode");
|
|
11
11
|
let pkg = {
|
|
12
12
|
name: '@rnmapbox/maps',
|
|
13
13
|
};
|
|
@@ -127,7 +127,7 @@ function setExcludedArchitectures(project) {
|
|
|
127
127
|
for (const { buildSettings } of Object.values(configurations || {})) {
|
|
128
128
|
// Guessing that this is the best way to emulate Xcode.
|
|
129
129
|
// Using `project.addToBuildSettings` modifies too many targets.
|
|
130
|
-
if (typeof
|
|
130
|
+
if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {
|
|
131
131
|
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taken from @expo/config-plugins
|
|
3
|
+
*
|
|
4
|
+
* Sourcecode: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/src/utils/generateCode.ts
|
|
5
|
+
* LICENSE: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/LICENSE
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get line indexes for the generated section of a file.
|
|
10
|
+
*
|
|
11
|
+
* @param src
|
|
12
|
+
*/
|
|
13
|
+
import crypto from 'crypto';
|
|
14
|
+
|
|
15
|
+
function getGeneratedSectionIndexes(
|
|
16
|
+
src: string,
|
|
17
|
+
tag: string,
|
|
18
|
+
): { contents: string[]; start: number; end: number } {
|
|
19
|
+
const contents = src.split('\n');
|
|
20
|
+
const start = contents.findIndex((line) =>
|
|
21
|
+
line.includes(`@generated begin ${tag}`),
|
|
22
|
+
);
|
|
23
|
+
const end = contents.findIndex((line) =>
|
|
24
|
+
line.includes(`@generated end ${tag}`),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return { contents, start, end };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type MergeResults = {
|
|
31
|
+
contents: string;
|
|
32
|
+
didClear: boolean;
|
|
33
|
+
didMerge: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Merge the contents of two files together and add a generated header.
|
|
38
|
+
*
|
|
39
|
+
* @param src contents of the original file
|
|
40
|
+
* @param newSrc new contents to merge into the original file
|
|
41
|
+
* @param identifier used to update and remove merges
|
|
42
|
+
* @param anchor regex to where the merge should begin
|
|
43
|
+
* @param offset line offset to start merging at (<1 for behind the anchor)
|
|
44
|
+
* @param comment comment style `//` or `#`
|
|
45
|
+
*/
|
|
46
|
+
export function mergeContents({
|
|
47
|
+
src,
|
|
48
|
+
newSrc,
|
|
49
|
+
tag,
|
|
50
|
+
anchor,
|
|
51
|
+
offset,
|
|
52
|
+
comment,
|
|
53
|
+
}: {
|
|
54
|
+
src: string;
|
|
55
|
+
newSrc: string;
|
|
56
|
+
tag: string;
|
|
57
|
+
anchor: string | RegExp;
|
|
58
|
+
offset: number;
|
|
59
|
+
comment: string;
|
|
60
|
+
}): MergeResults {
|
|
61
|
+
const header = createGeneratedHeaderComment(newSrc, tag, comment);
|
|
62
|
+
if (!src.includes(header)) {
|
|
63
|
+
// Ensure the old generated contents are removed.
|
|
64
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
65
|
+
return {
|
|
66
|
+
contents: addLines(sanitizedTarget ?? src, anchor, offset, [
|
|
67
|
+
header,
|
|
68
|
+
...newSrc.split('\n'),
|
|
69
|
+
`${comment} @generated end ${tag}`,
|
|
70
|
+
]),
|
|
71
|
+
didMerge: true,
|
|
72
|
+
didClear: !!sanitizedTarget,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return { contents: src, didClear: false, didMerge: false };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function removeContents({
|
|
79
|
+
src,
|
|
80
|
+
tag,
|
|
81
|
+
}: {
|
|
82
|
+
src: string;
|
|
83
|
+
tag: string;
|
|
84
|
+
}): MergeResults {
|
|
85
|
+
// Ensure the old generated contents are removed.
|
|
86
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
87
|
+
return {
|
|
88
|
+
contents: sanitizedTarget ?? src,
|
|
89
|
+
didMerge: false,
|
|
90
|
+
didClear: !!sanitizedTarget,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function addLines(
|
|
95
|
+
content: string,
|
|
96
|
+
find: string | RegExp,
|
|
97
|
+
offset: number,
|
|
98
|
+
toAdd: string[],
|
|
99
|
+
) {
|
|
100
|
+
const lines = content.split('\n');
|
|
101
|
+
|
|
102
|
+
let lineIndex = lines.findIndex((line) => line.match(find));
|
|
103
|
+
if (lineIndex < 0) {
|
|
104
|
+
const error = new Error(
|
|
105
|
+
`Failed to match "${find}" in contents:\n${content}`,
|
|
106
|
+
);
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
error.code = 'ERR_NO_MATCH';
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
for (const newLine of toAdd) {
|
|
113
|
+
lines.splice(lineIndex + offset, 0, newLine);
|
|
114
|
+
lineIndex++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return lines.join('\n');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Removes the generated section from a file, returns null when nothing can be removed.
|
|
122
|
+
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
|
|
123
|
+
*
|
|
124
|
+
* @param src
|
|
125
|
+
*/
|
|
126
|
+
export function removeGeneratedContents(
|
|
127
|
+
src: string,
|
|
128
|
+
tag: string,
|
|
129
|
+
): string | null {
|
|
130
|
+
const { contents, start, end } = getGeneratedSectionIndexes(src, tag);
|
|
131
|
+
if (start > -1 && end > -1 && start < end) {
|
|
132
|
+
contents.splice(start, end - start + 1);
|
|
133
|
+
// TODO: We could in theory check that the contents we're removing match the hash used in the header,
|
|
134
|
+
// this would ensure that we don't accidentally remove lines that someone added or removed from the generated section.
|
|
135
|
+
return contents.join('\n');
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function createGeneratedHeaderComment(
|
|
141
|
+
contents: string,
|
|
142
|
+
tag: string,
|
|
143
|
+
comment: string,
|
|
144
|
+
): string {
|
|
145
|
+
const hashKey = createHash(contents);
|
|
146
|
+
|
|
147
|
+
// Everything after the `${tag} ` is unversioned and can be freely modified without breaking changes.
|
|
148
|
+
return `${comment} @generated begin ${tag} - expo prebuild (DO NOT MODIFY) ${hashKey}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function createHash(src: string): string {
|
|
152
|
+
// this doesn't need to be secure, the shorter the better.
|
|
153
|
+
const hash = crypto.createHash('sha1').update(src).digest('hex');
|
|
154
|
+
return `sync-${hash}`;
|
|
155
|
+
}
|
package/plugin/src/withMapbox.ts
CHANGED
|
@@ -11,11 +11,9 @@ import {
|
|
|
11
11
|
WarningAggregator,
|
|
12
12
|
withProjectBuildGradle,
|
|
13
13
|
withAppBuildGradle,
|
|
14
|
-
} from '
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
removeGeneratedContents,
|
|
18
|
-
} from '@expo/config-plugins/build/utils/generateCode';
|
|
14
|
+
} from 'expo/config-plugins';
|
|
15
|
+
|
|
16
|
+
import { mergeContents, removeGeneratedContents } from './generateCode';
|
|
19
17
|
|
|
20
18
|
let pkg: { name: string; version?: string } = {
|
|
21
19
|
name: '@rnmapbox/maps',
|
package/rnmapbox-maps.podspec
CHANGED
|
@@ -20,7 +20,7 @@ require 'json'
|
|
|
20
20
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
21
21
|
|
|
22
22
|
## Warning: these lines are scanned by autogenerate.js
|
|
23
|
-
rnMapboxMapsDefaultMapboxVersion = '~> 10.9.
|
|
23
|
+
rnMapboxMapsDefaultMapboxVersion = '~> 10.9.1'
|
|
24
24
|
rnMapboxMapsDefaultMapboxGLVersion = '~> 5.9.0'
|
|
25
25
|
rnMapboxMapsDefaultMapLibreVersion = 'exactVersion 5.12.1'
|
|
26
26
|
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
package com.mapbox.rctmgl.components.location;
|
|
2
|
-
|
|
3
|
-
import android.annotation.SuppressLint;
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
import android.content.res.TypedArray;
|
|
6
|
-
import android.graphics.Color;
|
|
7
|
-
import android.graphics.ColorFilter;
|
|
8
|
-
import android.graphics.LightingColorFilter;
|
|
9
|
-
import android.graphics.drawable.Drawable;
|
|
10
|
-
import android.graphics.drawable.VectorDrawable;
|
|
11
|
-
|
|
12
|
-
import com.mapbox.geojson.Point;
|
|
13
|
-
import com.mapbox.maps.CameraOptions;
|
|
14
|
-
import com.mapbox.maps.MapboxMap;
|
|
15
|
-
import com.mapbox.maps.Style;
|
|
16
|
-
import com.mapbox.maps.plugin.LocationPuck;
|
|
17
|
-
import com.mapbox.maps.plugin.LocationPuck2D;
|
|
18
|
-
import com.mapbox.maps.plugin.gestures.GesturesUtils;
|
|
19
|
-
import com.mapbox.maps.plugin.locationcomponent.LocationComponentPlugin;
|
|
20
|
-
import com.mapbox.maps.plugin.locationcomponent.LocationComponentUtils;
|
|
21
|
-
import com.mapbox.maps.plugin.locationcomponent.OnIndicatorBearingChangedListener;
|
|
22
|
-
import com.mapbox.maps.plugin.locationcomponent.OnIndicatorPositionChangedListener;
|
|
23
|
-
import com.mapbox.maps.plugin.locationcomponent.generated.LocationComponentSettings;
|
|
24
|
-
import com.mapbox.rctmgl.R;
|
|
25
|
-
import com.mapbox.rctmgl.components.location.CameraMode;
|
|
26
|
-
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
|
|
27
|
-
import com.mapbox.rctmgl.location.LocationManager;
|
|
28
|
-
import com.mapbox.rctmgl.utils.Logger;
|
|
29
|
-
|
|
30
|
-
import androidx.annotation.NonNull;
|
|
31
|
-
import androidx.appcompat.content.res.AppCompatResources;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The LocationComponent on android implements both location tracking and display of user's current location.
|
|
35
|
-
* LocationComponentManager attempts to separate that, so that Camera can ask for location tracking independent of display of user current location.
|
|
36
|
-
* And NativeUserLocation can ask for display of user's current location - independent of Camera's user tracking.
|
|
37
|
-
*/
|
|
38
|
-
public class LocationComponentManager {
|
|
39
|
-
private RCTMGLMapView mMapView = null;
|
|
40
|
-
private MapboxMap mMap = null;
|
|
41
|
-
|
|
42
|
-
private LocationManager mLocationManager = null;
|
|
43
|
-
private LocationComponentPlugin mLocationComponent = null;
|
|
44
|
-
private Context mContext = null;
|
|
45
|
-
|
|
46
|
-
private int mCameraMode = CameraMode.NONE;
|
|
47
|
-
|
|
48
|
-
private @RenderMode.Mode int mRenderMode = RenderMode.COMPASS;
|
|
49
|
-
|
|
50
|
-
private OnIndicatorBearingChangedListener mLocationBearingChangedListener = new OnIndicatorBearingChangedListener() {
|
|
51
|
-
@Override
|
|
52
|
-
public void onIndicatorBearingChanged(double v) {
|
|
53
|
-
if (mFollowUserLocation) {
|
|
54
|
-
mMapView.getMapboxMap().setCamera(new CameraOptions.Builder().bearing(v).build());
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
private boolean bearingListenerInstalled = false;
|
|
59
|
-
|
|
60
|
-
private OnIndicatorPositionChangedListener mLocationPositionChangeListener = new OnIndicatorPositionChangedListener() {
|
|
61
|
-
@Override
|
|
62
|
-
public void onIndicatorPositionChanged(@NonNull Point point) {
|
|
63
|
-
if (mFollowUserLocation) {
|
|
64
|
-
mMapView.getMapboxMap().setCamera(new CameraOptions.Builder().center(point).build());
|
|
65
|
-
GesturesUtils.getGestures(mMapView).setFocalPoint(mMapView.getMapboxMap().pixelForCoordinate(point));
|
|
66
|
-
|
|
67
|
-
// sendUserLocationUpdateEvent(point);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
public LocationComponentManager(RCTMGLMapView rctmglMapView, Context context) {
|
|
73
|
-
mMapView = rctmglMapView;
|
|
74
|
-
mMap = mMapView.getMapboxMap();
|
|
75
|
-
mContext = context;
|
|
76
|
-
|
|
77
|
-
mLocationManager = LocationManager.getInstance(context);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private boolean mShowUserLocation = false;
|
|
81
|
-
|
|
82
|
-
private boolean mFollowUserLocation = false;
|
|
83
|
-
|
|
84
|
-
private boolean mShowingUserLocation = false;
|
|
85
|
-
|
|
86
|
-
public void showUserLocation(boolean showUserLocation) {
|
|
87
|
-
mShowUserLocation = showUserLocation;
|
|
88
|
-
stateChanged();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public void setFollowUserLocation(boolean followUserLocation) {
|
|
92
|
-
mFollowUserLocation = followUserLocation;
|
|
93
|
-
stateChanged();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public void setCameraMode(@CameraMode.Mode int cameraMode) {
|
|
97
|
-
mCameraMode = cameraMode;
|
|
98
|
-
stateChanged();
|
|
99
|
-
|
|
100
|
-
LocationComponentPlugin locationComponent = LocationComponentUtils.getLocationComponent(mMapView);
|
|
101
|
-
|
|
102
|
-
if (mCameraMode == CameraMode.NONE || mCameraMode == CameraMode.TRACKING) {
|
|
103
|
-
locationComponent.removeOnIndicatorBearingChangedListener(mLocationBearingChangedListener);
|
|
104
|
-
} else {
|
|
105
|
-
locationComponent.addOnIndicatorBearingChangedListener(mLocationBearingChangedListener);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (mCameraMode == CameraMode.NONE || mCameraMode == CameraMode.NONE_COMPASS || mCameraMode == CameraMode.NONE_GPS) {
|
|
109
|
-
locationComponent.removeOnIndicatorPositionChangedListener(mLocationPositionChangeListener);
|
|
110
|
-
} else {
|
|
111
|
-
locationComponent.addOnIndicatorPositionChangedListener(mLocationPositionChangeListener);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public void tintColorChanged() {
|
|
116
|
-
applyOptions(mShowingUserLocation, mLocationComponent);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public void setRenderMode(@RenderMode.Mode int renderMode) {
|
|
120
|
-
mRenderMode = renderMode;
|
|
121
|
-
}
|
|
122
|
-
/*
|
|
123
|
-
public void addOnCameraTrackingChangedListener(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
|
|
124
|
-
// mLocationComponent.addOnCameraTrackingChangedListener(onCameraTrackingChangedListener);
|
|
125
|
-
}*/
|
|
126
|
-
|
|
127
|
-
@SuppressLint("MissingPermission")
|
|
128
|
-
private void stateChanged() {
|
|
129
|
-
mLocationComponent.setEnabled((mFollowUserLocation || mShowUserLocation));
|
|
130
|
-
|
|
131
|
-
if (mShowingUserLocation != mShowUserLocation) {
|
|
132
|
-
updateShowUserLocation(mShowUserLocation);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (mFollowUserLocation) {
|
|
136
|
-
if (!mShowUserLocation) {
|
|
137
|
-
// mLocationComponent.setRenderMode(RenderMode.GPS);
|
|
138
|
-
} else {
|
|
139
|
-
// mLocationComponent.setRenderMode(mRenderMode);
|
|
140
|
-
}
|
|
141
|
-
mLocationComponent.onStart();
|
|
142
|
-
} else {
|
|
143
|
-
// mLocationComponent.setCameraMode(CameraMode.NONE);
|
|
144
|
-
}
|
|
145
|
-
mLocationComponent.setEnabled(mFollowUserLocation || mShowUserLocation);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public boolean hasLocationComponent() {
|
|
149
|
-
return (mLocationComponent != null);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public void update(@NonNull Style style) {
|
|
153
|
-
update(mShowUserLocation, style);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public void update(boolean displayUserLocation, @NonNull Style style) {
|
|
157
|
-
if (mLocationComponent == null) {
|
|
158
|
-
mLocationComponent = LocationComponentUtils.getLocationComponent(mMapView);
|
|
159
|
-
|
|
160
|
-
mLocationComponent.setLocationProvider(mLocationManager.getProvider());
|
|
161
|
-
mShowingUserLocation = displayUserLocation;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
updateShowUserLocation(displayUserLocation);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private void updateShowUserLocation(boolean displayUserLocation) {
|
|
168
|
-
if (mShowingUserLocation != displayUserLocation) {
|
|
169
|
-
applyOptions(displayUserLocation, mLocationComponent);
|
|
170
|
-
mShowingUserLocation = displayUserLocation;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private void applyOptions(boolean displayUserLocation, LocationComponentPlugin locationComponent) {
|
|
175
|
-
locationComponent.setEnabled(true);
|
|
176
|
-
if (!displayUserLocation) {
|
|
177
|
-
LocationPuck2D locationPuck = new LocationPuck2D();
|
|
178
|
-
|
|
179
|
-
Drawable empty = AppCompatResources.getDrawable(mContext, R.drawable.empty);
|
|
180
|
-
locationPuck.setBearingImage(empty);
|
|
181
|
-
locationPuck.setShadowImage(empty);
|
|
182
|
-
locationPuck.setTopImage(empty);
|
|
183
|
-
|
|
184
|
-
locationComponent.setLocationPuck(locationPuck);
|
|
185
|
-
locationComponent.setPulsingEnabled(false);
|
|
186
|
-
} else {
|
|
187
|
-
int mapboxBlueColor = Color.parseColor("#4A90E2");
|
|
188
|
-
|
|
189
|
-
LocationPuck2D locationPuck = new LocationPuck2D();
|
|
190
|
-
Drawable topImage = AppCompatResources.getDrawable(mContext, R.drawable.mapbox_user_icon);
|
|
191
|
-
|
|
192
|
-
Integer tintColor = mMapView.getTintColor();
|
|
193
|
-
if (tintColor != null) {
|
|
194
|
-
VectorDrawable drawable = (VectorDrawable)topImage;
|
|
195
|
-
drawable.setTint(tintColor);
|
|
196
|
-
|
|
197
|
-
topImage = drawable;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
locationPuck.setTopImage(topImage);
|
|
201
|
-
Drawable bearingImage = AppCompatResources.getDrawable(mContext, R.drawable.mapbox_user_stroke_icon);
|
|
202
|
-
locationPuck.setBearingImage(bearingImage);
|
|
203
|
-
Drawable shadowImage = AppCompatResources.getDrawable(mContext, R.drawable.mapbox_user_icon_shadow);
|
|
204
|
-
locationPuck.setShadowImage(shadowImage);
|
|
205
|
-
locationComponent.setLocationPuck(locationPuck);
|
|
206
|
-
|
|
207
|
-
locationComponent.setPulsingEnabled(true);
|
|
208
|
-
if (tintColor != null) {
|
|
209
|
-
locationComponent.setPulsingColor(tintColor);
|
|
210
|
-
} else {
|
|
211
|
-
locationComponent.setPulsingColor(mapboxBlueColor);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/RenderMode.java
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
package com.mapbox.rctmgl.components.location;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.IntDef;
|
|
4
|
-
|
|
5
|
-
import java.lang.annotation.Retention;
|
|
6
|
-
import java.lang.annotation.RetentionPolicy;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Contains the variety of ways the user location can be rendered on the map.
|
|
10
|
-
*/
|
|
11
|
-
public final class RenderMode {
|
|
12
|
-
|
|
13
|
-
private RenderMode() {
|
|
14
|
-
// Class should not be initialized
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* One of these constants should be used with {@link LocationComponent#setRenderMode(int)}.
|
|
19
|
-
* Mode can be switched at anytime by calling the {@code setLocationLayerMode} method passing
|
|
20
|
-
* in the new mode you'd like the location layer to be in.
|
|
21
|
-
*/
|
|
22
|
-
@IntDef( {COMPASS, GPS, NORMAL})
|
|
23
|
-
@Retention(RetentionPolicy.SOURCE)
|
|
24
|
-
public @interface Mode {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Basic tracking is enabled, bearing ignored.
|
|
29
|
-
*/
|
|
30
|
-
public static final int NORMAL = 0x00000012;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Tracking the user location with bearing considered
|
|
34
|
-
* from a {@link CompassEngine}.
|
|
35
|
-
*/
|
|
36
|
-
public static final int COMPASS = 0x00000004;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Tracking the user location with bearing considered from {@link android.location.Location}.
|
|
40
|
-
*/
|
|
41
|
-
public static final int GPS = 0x00000008;
|
|
42
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
package com.mapbox.rctmgl.events;
|
|
2
|
-
|
|
3
|
-
import android.location.Location;
|
|
4
|
-
import androidx.annotation.NonNull;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.bridge.Arguments;
|
|
7
|
-
import com.facebook.react.bridge.WritableMap;
|
|
8
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
-
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
|
|
10
|
-
import com.mapbox.rctmgl.events.constants.EventKeys;
|
|
11
|
-
import com.mapbox.rctmgl.events.constants.EventTypes;
|
|
12
|
-
|
|
13
|
-
import java.util.UUID;
|
|
14
|
-
|
|
15
|
-
public class LocationEvent implements IEvent {
|
|
16
|
-
private UUID uuid;
|
|
17
|
-
private RCTMGLMapView mapView;
|
|
18
|
-
private Location location;
|
|
19
|
-
|
|
20
|
-
public LocationEvent(@NonNull Location location, RCTMGLMapView mapView) {
|
|
21
|
-
this.mapView = mapView;
|
|
22
|
-
this.location = location;
|
|
23
|
-
this.uuid = UUID.randomUUID();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public LocationEvent(Location location) {
|
|
27
|
-
this(location, null);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Override
|
|
31
|
-
public int getID() {
|
|
32
|
-
if (mapView != null) {
|
|
33
|
-
return mapView.getId();
|
|
34
|
-
}
|
|
35
|
-
return -1;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public UUID getUUID() {
|
|
39
|
-
return uuid;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Override
|
|
43
|
-
public String getKey() {
|
|
44
|
-
return EventKeys.USER_LOCATION_UPDATE;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@Override
|
|
48
|
-
public String getType() {
|
|
49
|
-
return EventTypes.USER_LOCATION_UPDATED;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Override
|
|
53
|
-
public long getTimestamp() {
|
|
54
|
-
return System.currentTimeMillis();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Override
|
|
58
|
-
public boolean equals(IEvent event) {
|
|
59
|
-
LocationEvent other = (LocationEvent) event;
|
|
60
|
-
return getUUID().equals(other.getUUID());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public boolean equals(LocationEvent event) {
|
|
64
|
-
return uuid.equals(event.getUUID());
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Override
|
|
68
|
-
public WritableMap getPayload() {
|
|
69
|
-
WritableMap positionProperties = new WritableNativeMap();
|
|
70
|
-
WritableMap coords = new WritableNativeMap();
|
|
71
|
-
|
|
72
|
-
coords.putDouble("longitude", location.getLongitude());
|
|
73
|
-
coords.putDouble("latitude", location.getLatitude());
|
|
74
|
-
coords.putDouble("altitude", location.getAltitude());
|
|
75
|
-
coords.putDouble("accuracy", location.getAccuracy());
|
|
76
|
-
// A better solution will be to pull the heading from the compass engine,
|
|
77
|
-
// unfortunately the api is not publicly available in the mapbox sdk
|
|
78
|
-
coords.putDouble("heading", location.getBearing());
|
|
79
|
-
coords.putDouble("course", location.getBearing());
|
|
80
|
-
coords.putDouble("speed", location.getSpeed());
|
|
81
|
-
|
|
82
|
-
positionProperties.putMap("coords", coords);
|
|
83
|
-
positionProperties.putDouble("timestamp", location.getTime());
|
|
84
|
-
|
|
85
|
-
return positionProperties;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@Override
|
|
89
|
-
public WritableMap toJSON() {
|
|
90
|
-
WritableMap map = Arguments.createMap();
|
|
91
|
-
map.putString("type", getType());
|
|
92
|
-
map.putMap("payload", getPayload());
|
|
93
|
-
return map;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Override
|
|
97
|
-
public boolean canCoalesce() {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|