@nativescript-community/ui-mapbox 6.2.9 → 6.2.13
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/CHANGELOG.md +36 -0
- package/README.md +199 -99
- package/{mapbox.common.d.ts → common.d.ts} +20 -3
- package/{mapbox.common.js → common.js} +18 -1
- package/{filter/filter-parser.android.d.ts → expression/expression-parser.android.d.ts} +1 -1
- package/{filter/filter-parser.android.js → expression/expression-parser.android.js} +2 -2
- package/expression/expression-parser.d.ts +4 -0
- package/{filter/filter-parser.ios.d.ts → expression/expression-parser.ios.d.ts} +1 -1
- package/{filter/filter-parser.ios.js → expression/expression-parser.ios.js} +2 -2
- package/{mapbox.android.d.ts → index.android.d.ts} +5 -14
- package/{mapbox.android.js → index.android.js} +142 -66
- package/index.d.ts +98 -6
- package/{mapbox.ios.d.ts → index.ios.d.ts} +3 -30
- package/{mapbox.ios.js → index.ios.js} +1300 -1250
- package/layers/layer-factory.android.d.ts +14 -1
- package/layers/layer-factory.android.js +33 -2
- package/layers/layer-factory.d.ts +15 -1
- package/layers/layer-factory.ios.d.ts +14 -1
- package/layers/layer-factory.ios.js +42 -2
- package/layers/parser/property-parser.android.d.ts +1 -0
- package/layers/parser/property-parser.android.js +25 -0
- package/layers/parser/property-parser.d.ts +4 -0
- package/layers/parser/property-parser.ios.d.ts +1 -0
- package/layers/parser/property-parser.ios.js +21 -0
- package/package.json +55 -49
- package/platforms/android/include.gradle +4 -1
- package/platforms/android/ui_mapbox.aar +0 -0
- package/platforms/ios/Podfile +2 -2
- package/typings/Mapbox.ios.d.ts +2 -0
- package/LICENSE +0 -21
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { request } from '@nativescript-community/perms';
|
|
2
|
-
import { AndroidApplication, Application, Color, File, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxTraceCategory, MapboxViewBase, telemetryProperty } from './mapbox.common';
|
|
8
|
-
export { MapboxTraceCategory, MapStyle };
|
|
2
|
+
import { AndroidApplication, Application, Color, File, Http, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
|
3
|
+
import { ExpressionParser } from './expression/expression-parser';
|
|
4
|
+
import { Layer, LayerFactory } from './layers/layer-factory';
|
|
5
|
+
import { CLog, CLogTypes, MapStyle, MapboxCommon, MapboxViewBase, telemetryProperty } from './common';
|
|
6
|
+
export * from './common';
|
|
9
7
|
function _getLocation(loc) {
|
|
10
8
|
if (loc === null) {
|
|
11
9
|
return null;
|
|
@@ -186,6 +184,18 @@ export class MapboxView extends MapboxViewBase {
|
|
|
186
184
|
map: this,
|
|
187
185
|
android: this.nativeMapView
|
|
188
186
|
});
|
|
187
|
+
},
|
|
188
|
+
onMoveEndEvent: (event) => {
|
|
189
|
+
if (Trace.isEnabled()) {
|
|
190
|
+
CLog(CLogTypes.info, 'initMap(): onMoveEndEvent event');
|
|
191
|
+
}
|
|
192
|
+
this.notify({
|
|
193
|
+
eventName: MapboxViewBase.moveEndEvent,
|
|
194
|
+
object: this,
|
|
195
|
+
event,
|
|
196
|
+
map: this,
|
|
197
|
+
android: this.nativeMapView
|
|
198
|
+
});
|
|
189
199
|
}
|
|
190
200
|
};
|
|
191
201
|
if (Trace.isEnabled()) {
|
|
@@ -208,7 +218,9 @@ export class MapboxView extends MapboxViewBase {
|
|
|
208
218
|
}
|
|
209
219
|
}
|
|
210
220
|
[telemetryProperty.setNative](value) {
|
|
211
|
-
com.mapbox.mapboxsdk.Mapbox.getTelemetry()
|
|
221
|
+
if (com.mapbox.mapboxsdk.Mapbox.getTelemetry()) {
|
|
222
|
+
com.mapbox.mapboxsdk.Mapbox.getTelemetry().setUserTelemetryRequestState(value);
|
|
223
|
+
}
|
|
212
224
|
}
|
|
213
225
|
}
|
|
214
226
|
export class Mapbox extends MapboxCommon {
|
|
@@ -294,7 +306,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
294
306
|
if (settings.showUserLocation) {
|
|
295
307
|
this.requestFineLocationPermission()
|
|
296
308
|
.then(() => {
|
|
297
|
-
this.showUserLocationMarker(
|
|
309
|
+
this.showUserLocationMarker(settings.locationComponentOptions);
|
|
298
310
|
if (settings.onLocationPermissionGranted) {
|
|
299
311
|
settings.onLocationPermissionGranted(this._mapboxMapInstance);
|
|
300
312
|
}
|
|
@@ -552,6 +564,22 @@ export class Mapbox extends MapboxCommon {
|
|
|
552
564
|
settings.onMoveBeginEvent(point);
|
|
553
565
|
}
|
|
554
566
|
}, mapboxNativeViewInstance);
|
|
567
|
+
this.setOnMoveEndListener((point) => {
|
|
568
|
+
if (Trace.isEnabled()) {
|
|
569
|
+
CLog(CLogTypes.info, 'Mapbox:initEventHandlerShim(): moveEnd:', point);
|
|
570
|
+
}
|
|
571
|
+
if (typeof settings.onMoveEndEvent != 'undefined') {
|
|
572
|
+
settings.onMoveEndEvent(point);
|
|
573
|
+
}
|
|
574
|
+
}, mapboxNativeViewInstance);
|
|
575
|
+
this.setOnScrollListener((point) => {
|
|
576
|
+
if (Trace.isEnabled()) {
|
|
577
|
+
CLog(CLogTypes.info, 'Mapbox:initEventHandlerShim(): move:', point);
|
|
578
|
+
}
|
|
579
|
+
if (typeof settings.onScrollEvent != 'undefined') {
|
|
580
|
+
settings.onScrollEvent(point);
|
|
581
|
+
}
|
|
582
|
+
}, mapboxNativeViewInstance);
|
|
555
583
|
}
|
|
556
584
|
onMapEvent(eventName, id, callback, nativeMapView) {
|
|
557
585
|
if (typeof this.eventCallbacks[eventName] == 'undefined') {
|
|
@@ -1057,7 +1085,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1057
1085
|
const mapboxPoint = new com.mapbox.mapboxsdk.geometry.LatLng(options.point.lat, options.point.lng);
|
|
1058
1086
|
const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
|
|
1059
1087
|
if (this._mapboxMapInstance.queryRenderedFeatures) {
|
|
1060
|
-
const queryFilter = options.filter ?
|
|
1088
|
+
const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
|
|
1061
1089
|
const features = this._mapboxMapInstance.queryRenderedFeatures(screenLocation, queryFilter, options.layers);
|
|
1062
1090
|
const result = [];
|
|
1063
1091
|
for (let i = 0; i < features.size(); i++) {
|
|
@@ -1089,7 +1117,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1089
1117
|
throw new Error(`Source with id "${sourceId}" not found.`);
|
|
1090
1118
|
}
|
|
1091
1119
|
let features;
|
|
1092
|
-
const queryFilter = options.filter ?
|
|
1120
|
+
const queryFilter = options.filter ? ExpressionParser.parseJson(options.filter) : null;
|
|
1093
1121
|
if (source instanceof com.mapbox.mapboxsdk.style.sources.GeoJsonSource) {
|
|
1094
1122
|
features = source.querySourceFeatures(queryFilter);
|
|
1095
1123
|
}
|
|
@@ -1344,6 +1372,38 @@ export class Mapbox extends MapboxCommon {
|
|
|
1344
1372
|
}
|
|
1345
1373
|
});
|
|
1346
1374
|
}
|
|
1375
|
+
setOnMoveEndListener(listener, nativeMap) {
|
|
1376
|
+
return new Promise((resolve, reject) => {
|
|
1377
|
+
try {
|
|
1378
|
+
if (!this._mapboxMapInstance) {
|
|
1379
|
+
reject('No map has been loaded');
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
if (Trace.isEnabled()) {
|
|
1383
|
+
CLog(CLogTypes.info, 'setOnMoveEndListener():');
|
|
1384
|
+
}
|
|
1385
|
+
this.onMoveListener = new com.mapbox.mapboxsdk.maps.MapboxMap.OnMoveListener({
|
|
1386
|
+
onMoveBegin: (detector) => { },
|
|
1387
|
+
onMove: (detector) => { },
|
|
1388
|
+
onMoveEnd: (detector) => {
|
|
1389
|
+
const coordinate = this._mapboxMapInstance.getCameraPosition().target;
|
|
1390
|
+
return listener({
|
|
1391
|
+
lat: coordinate.getLatitude(),
|
|
1392
|
+
lng: coordinate.getLongitude()
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
this._mapboxMapInstance.addOnMoveListener(this.onMoveListener);
|
|
1397
|
+
resolve();
|
|
1398
|
+
}
|
|
1399
|
+
catch (ex) {
|
|
1400
|
+
if (Trace.isEnabled()) {
|
|
1401
|
+
CLog(CLogTypes.info, 'Error in mapbox.setOnMoveEndListener: ' + ex);
|
|
1402
|
+
}
|
|
1403
|
+
reject(ex);
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1347
1407
|
setOnScrollListener(listener, nativeMap) {
|
|
1348
1408
|
return new Promise((resolve, reject) => {
|
|
1349
1409
|
try {
|
|
@@ -1526,8 +1586,8 @@ export class Mapbox extends MapboxCommon {
|
|
|
1526
1586
|
.build();
|
|
1527
1587
|
const retinaFactor = Utils.layout.getDisplayDensity();
|
|
1528
1588
|
const offlineRegionDefinition = new com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition(styleURL, bounds, options.minZoom, options.maxZoom, retinaFactor);
|
|
1529
|
-
const info =
|
|
1530
|
-
const infoStr = new java.lang.String(info);
|
|
1589
|
+
const info = Object.assign({ name: options.name }, options.metadata);
|
|
1590
|
+
const infoStr = new java.lang.String(JSON.stringify(info));
|
|
1531
1591
|
const encodedMetadata = infoStr.getBytes();
|
|
1532
1592
|
if (!this._accessToken && !options.accessToken) {
|
|
1533
1593
|
reject("First show a map, or pass in an 'accessToken' param");
|
|
@@ -1557,7 +1617,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1557
1617
|
});
|
|
1558
1618
|
}
|
|
1559
1619
|
if (status.isComplete()) {
|
|
1560
|
-
resolve();
|
|
1620
|
+
resolve(status);
|
|
1561
1621
|
}
|
|
1562
1622
|
else if (status.isRequiredResourceCountPrecise()) {
|
|
1563
1623
|
}
|
|
@@ -1603,7 +1663,9 @@ export class Mapbox extends MapboxCommon {
|
|
|
1603
1663
|
const name = this._getRegionName(offlineRegion);
|
|
1604
1664
|
const offlineRegionDefinition = offlineRegion.getDefinition();
|
|
1605
1665
|
const bounds = offlineRegionDefinition.getBounds();
|
|
1666
|
+
const metadata = this._getRegionMetadata(offlineRegion);
|
|
1606
1667
|
regions.push({
|
|
1668
|
+
id: offlineRegion.getID(),
|
|
1607
1669
|
name,
|
|
1608
1670
|
style: offlineRegionDefinition.getStyleURL(),
|
|
1609
1671
|
minZoom: offlineRegionDefinition.getMinZoom(),
|
|
@@ -1613,7 +1675,10 @@ export class Mapbox extends MapboxCommon {
|
|
|
1613
1675
|
east: bounds.getLonEast(),
|
|
1614
1676
|
south: bounds.getLatSouth(),
|
|
1615
1677
|
west: bounds.getLonWest()
|
|
1616
|
-
}
|
|
1678
|
+
},
|
|
1679
|
+
metadata,
|
|
1680
|
+
pixelRatio: offlineRegionDefinition.getPixelRatio(),
|
|
1681
|
+
type: offlineRegionDefinition.getType()
|
|
1617
1682
|
});
|
|
1618
1683
|
}
|
|
1619
1684
|
}
|
|
@@ -1632,8 +1697,8 @@ export class Mapbox extends MapboxCommon {
|
|
|
1632
1697
|
deleteOfflineRegion(options) {
|
|
1633
1698
|
return new Promise((resolve, reject) => {
|
|
1634
1699
|
try {
|
|
1635
|
-
if (!options || !options.name) {
|
|
1636
|
-
reject("Pass in the 'name' param");
|
|
1700
|
+
if (!options || (!options.id && !options.name)) {
|
|
1701
|
+
reject("Pass in the 'id' or 'name' param");
|
|
1637
1702
|
return;
|
|
1638
1703
|
}
|
|
1639
1704
|
this._getOfflineManager().listOfflineRegions(new com.mapbox.mapboxsdk.offline.OfflineManager.ListOfflineRegionsCallback({
|
|
@@ -1646,8 +1711,8 @@ export class Mapbox extends MapboxCommon {
|
|
|
1646
1711
|
if (offlineRegions !== null) {
|
|
1647
1712
|
for (let i = 0; i < offlineRegions.length; i++) {
|
|
1648
1713
|
const offlineRegion = offlineRegions[i];
|
|
1649
|
-
const
|
|
1650
|
-
if (
|
|
1714
|
+
const regionId = options.id ? offlineRegion.getID() : this._getRegionName(offlineRegion);
|
|
1715
|
+
if (regionId === (options.id || options.name)) {
|
|
1651
1716
|
found = true;
|
|
1652
1717
|
offlineRegion.delete(new com.mapbox.mapboxsdk.offline.OfflineRegion.OfflineRegionDeleteCallback({
|
|
1653
1718
|
onError: (error) => {
|
|
@@ -1668,7 +1733,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1668
1733
|
}
|
|
1669
1734
|
catch (ex) {
|
|
1670
1735
|
if (Trace.isEnabled()) {
|
|
1671
|
-
CLog(CLogTypes.info, 'Error in mapbox.
|
|
1736
|
+
CLog(CLogTypes.info, 'Error in mapbox.deleteOfflineRegion: ' + ex);
|
|
1672
1737
|
}
|
|
1673
1738
|
reject(ex);
|
|
1674
1739
|
}
|
|
@@ -1790,6 +1855,16 @@ export class Mapbox extends MapboxCommon {
|
|
|
1790
1855
|
.withCluster(true)
|
|
1791
1856
|
.withClusterMaxZoom(options.cluster.maxZoom || 13)
|
|
1792
1857
|
.withClusterRadius(options.cluster.radius || 40);
|
|
1858
|
+
if (options.cluster.properties) {
|
|
1859
|
+
for (const property of Object.keys(options.cluster.properties)) {
|
|
1860
|
+
const propertyValues = options.cluster.properties[property];
|
|
1861
|
+
let operator = propertyValues[0];
|
|
1862
|
+
if (!Array.isArray(operator)) {
|
|
1863
|
+
operator = [operator];
|
|
1864
|
+
}
|
|
1865
|
+
geojsonOptions.withClusterProperty(property, ExpressionParser.parseJson(operator), ExpressionParser.parseJson(propertyValues[1]));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1793
1868
|
}
|
|
1794
1869
|
const geoJsonSource = new com.mapbox.mapboxsdk.style.sources.GeoJsonSource(id, geojsonOptions);
|
|
1795
1870
|
if (options.data) {
|
|
@@ -1896,7 +1971,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
1896
1971
|
if (!lineSource) {
|
|
1897
1972
|
throw new Error(`no source found with id: ${sId}`);
|
|
1898
1973
|
}
|
|
1899
|
-
const lineFeatures = lineSource.querySourceFeatures(
|
|
1974
|
+
const lineFeatures = lineSource.querySourceFeatures(ExpressionParser.parseJson(['==', '$type', 'LineString']));
|
|
1900
1975
|
if (lineFeatures.size() === 0) {
|
|
1901
1976
|
throw new Error('no line string feature found');
|
|
1902
1977
|
}
|
|
@@ -1984,9 +2059,14 @@ export class Mapbox extends MapboxCommon {
|
|
|
1984
2059
|
}
|
|
1985
2060
|
this.requestFineLocationPermission()
|
|
1986
2061
|
.then(() => {
|
|
1987
|
-
this.
|
|
1988
|
-
|
|
1989
|
-
}
|
|
2062
|
+
if (this._locationComponent) {
|
|
2063
|
+
this.changeUserLocationMarkerMode(options.renderMode || 'COMPASS', options.cameraMode || 'TRACKING');
|
|
2064
|
+
}
|
|
2065
|
+
else {
|
|
2066
|
+
this.showUserLocationMarker({
|
|
2067
|
+
useDefaultLocationEngine: true
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
1990
2070
|
})
|
|
1991
2071
|
.catch((err) => {
|
|
1992
2072
|
console.error('Location permission denied. error:', err);
|
|
@@ -2081,11 +2161,11 @@ export class Mapbox extends MapboxCommon {
|
|
|
2081
2161
|
return modeRef.NONE_GPS;
|
|
2082
2162
|
case 'TRACKING':
|
|
2083
2163
|
return modeRef.TRACKING;
|
|
2084
|
-
case '
|
|
2164
|
+
case 'TRACKING_COMPASS':
|
|
2085
2165
|
return modeRef.TRACKING_COMPASS;
|
|
2086
2166
|
case 'TRACKING_GPS':
|
|
2087
2167
|
return modeRef.TRACKING_GPS;
|
|
2088
|
-
case '
|
|
2168
|
+
case 'TRACKING_GPS_NORTH':
|
|
2089
2169
|
return modeRef.TRACKING_GPS_NORTH;
|
|
2090
2170
|
}
|
|
2091
2171
|
}
|
|
@@ -2115,7 +2195,18 @@ export class Mapbox extends MapboxCommon {
|
|
|
2115
2195
|
const metadata = offlineRegion.getMetadata();
|
|
2116
2196
|
const jsonStr = new java.lang.String(metadata, 'UTF-8');
|
|
2117
2197
|
const jsonObj = new org.json.JSONObject(jsonStr);
|
|
2118
|
-
|
|
2198
|
+
try {
|
|
2199
|
+
return jsonObj.getString('name');
|
|
2200
|
+
}
|
|
2201
|
+
catch (error) {
|
|
2202
|
+
return '';
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
_getRegionMetadata(offlineRegion) {
|
|
2206
|
+
const metadata = offlineRegion.getMetadata();
|
|
2207
|
+
const jsonStr = new java.lang.String(metadata, 'UTF-8');
|
|
2208
|
+
const jsonObj = new org.json.JSONObject(jsonStr);
|
|
2209
|
+
return JSON.parse(jsonObj.toString());
|
|
2119
2210
|
}
|
|
2120
2211
|
showUserLocationMarker(options, nativeMap) {
|
|
2121
2212
|
return new Promise((resolve, reject) => {
|
|
@@ -2241,23 +2332,32 @@ export class Mapbox extends MapboxCommon {
|
|
|
2241
2332
|
reject('No location component has been loaded');
|
|
2242
2333
|
return;
|
|
2243
2334
|
}
|
|
2244
|
-
if (
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2335
|
+
if (cameraModeString) {
|
|
2336
|
+
const cameraMode = this._stringToCameraMode(cameraModeString);
|
|
2337
|
+
if (Trace.isEnabled()) {
|
|
2338
|
+
CLog(CLogTypes.info, `Mapbox::changeUserLocationMarkerMode(): current camera mode is: ${this._locationComponent.getCameraMode()}`);
|
|
2339
|
+
CLog(CLogTypes.info, `Mapbox::changeUserLocationMarkerMode(): changing camera mode to: ${cameraMode}`);
|
|
2340
|
+
}
|
|
2341
|
+
this._locationComponent.setCameraMode(cameraMode);
|
|
2342
|
+
if (Trace.isEnabled()) {
|
|
2343
|
+
CLog(CLogTypes.info, `Mapbox::changeUserLocationMarkerMode(): new camera mode is: ${this._locationComponent.getCameraMode()}`);
|
|
2344
|
+
}
|
|
2249
2345
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2346
|
+
if (renderModeString) {
|
|
2347
|
+
const renderMode = this._stringToRenderMode(renderModeString);
|
|
2348
|
+
if (Trace.isEnabled()) {
|
|
2349
|
+
CLog(CLogTypes.info, `Mapbox::changeUserLocationMarkerMode(): current render mode is: ${this._locationComponent.getRenderMode()}`);
|
|
2350
|
+
CLog(CLogTypes.info, `Mapbox::changeUserLocationMarkerMode(): changing render mode to: '${renderMode}'`);
|
|
2351
|
+
}
|
|
2352
|
+
this._locationComponent.setRenderMode(renderMode);
|
|
2353
|
+
if (Trace.isEnabled()) {
|
|
2354
|
+
CLog(CLogTypes.info, 'changeUserLocationMarkerMode(): new render mode is:', this._locationComponent.getRenderMode());
|
|
2355
|
+
}
|
|
2256
2356
|
}
|
|
2257
2357
|
}
|
|
2258
2358
|
catch (ex) {
|
|
2259
2359
|
if (Trace.isEnabled()) {
|
|
2260
|
-
CLog(CLogTypes.info, 'Error in mapbox.
|
|
2360
|
+
CLog(CLogTypes.info, 'Error in mapbox.changeUserLocationMarkerMode: ' + ex);
|
|
2261
2361
|
}
|
|
2262
2362
|
reject(ex);
|
|
2263
2363
|
}
|
|
@@ -2358,7 +2458,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2358
2458
|
resolve(marker);
|
|
2359
2459
|
return;
|
|
2360
2460
|
}
|
|
2361
|
-
getImage(marker.icon).then((output) => {
|
|
2461
|
+
Http.getImage(marker.icon).then((output) => {
|
|
2362
2462
|
marker.iconDownloaded = output.android;
|
|
2363
2463
|
this._markerIconDownloadCache[marker.icon] = marker.iconDownloaded;
|
|
2364
2464
|
resolve(marker);
|
|
@@ -2388,31 +2488,7 @@ export class Mapbox extends MapboxCommon {
|
|
|
2388
2488
|
project(data) {
|
|
2389
2489
|
const mapboxPoint = new com.mapbox.mapboxsdk.geometry.LatLng(data.lat, data.lng);
|
|
2390
2490
|
const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
|
|
2391
|
-
return { x: layout.toDeviceIndependentPixels(screenLocation.x), y: layout.toDeviceIndependentPixels(screenLocation.y) };
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
export class Layer {
|
|
2395
|
-
constructor(instance) {
|
|
2396
|
-
this.instance = instance;
|
|
2397
|
-
this.id = instance.getId();
|
|
2398
|
-
}
|
|
2399
|
-
visibility() {
|
|
2400
|
-
return this.instance.getVisibility().getValue() === 'visible' ? true : false;
|
|
2401
|
-
}
|
|
2402
|
-
show() {
|
|
2403
|
-
this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'visible')]);
|
|
2404
|
-
}
|
|
2405
|
-
hide() {
|
|
2406
|
-
this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'none')]);
|
|
2407
|
-
}
|
|
2408
|
-
getNativeInstance() {
|
|
2409
|
-
return this.instance;
|
|
2410
|
-
}
|
|
2411
|
-
setFilter(filter) {
|
|
2412
|
-
this.instance.setFilter(FilterParser.parseJson(filter));
|
|
2413
|
-
}
|
|
2414
|
-
getFilter() {
|
|
2415
|
-
return FilterParser.toJson(this.instance.getFilter());
|
|
2491
|
+
return { x: Utils.layout.toDeviceIndependentPixels(screenLocation.x), y: Utils.layout.toDeviceIndependentPixels(screenLocation.y) };
|
|
2416
2492
|
}
|
|
2417
2493
|
}
|
|
2418
|
-
//# sourceMappingURL=
|
|
2494
|
+
//# sourceMappingURL=index.android.js.map
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* It doesn't matter if you export `.ios` or `.android`, either one but only one.
|
|
4
|
-
*/
|
|
5
|
-
export * from './mapbox.ios';
|
|
1
|
+
import { ImageSource } from '@nativescript/core';
|
|
2
|
+
import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, MapStyle, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport } from './common';
|
|
6
3
|
|
|
7
4
|
// Export any shared classes, constants, etc.
|
|
8
|
-
export * from './
|
|
5
|
+
export * from './common';
|
|
6
|
+
|
|
7
|
+
export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' | 'fault' | 'verbose'): void;
|
|
8
|
+
export declare class MapboxView extends MapboxViewBase {
|
|
9
|
+
private nativeMapView;
|
|
10
|
+
private delegate;
|
|
11
|
+
private settings;
|
|
12
|
+
private initialized;
|
|
13
|
+
private initCountHack;
|
|
14
|
+
setConfig(settings: any): void;
|
|
15
|
+
getNativeMapView(): any;
|
|
16
|
+
createNativeView(): Object;
|
|
17
|
+
onLoaded(): void;
|
|
18
|
+
initNativeView(): void;
|
|
19
|
+
disposeNativeView(): Promise<void>;
|
|
20
|
+
getMapboxApi(): any;
|
|
21
|
+
initMap(): void;
|
|
22
|
+
onLayout(left: number, top: number, right: number, bottom: number): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
25
|
+
private _mapboxViewInstance;
|
|
26
|
+
private eventCallbacks;
|
|
27
|
+
private userLocationRenderMode;
|
|
28
|
+
setMapboxViewInstance(mapboxViewInstance: any): void;
|
|
29
|
+
initEventHandlerShim(settings: any, mapboxNativeViewInstance: any): void;
|
|
30
|
+
onMapEvent(eventName: any, id: any, callback: any, nativeMapView?: any): void;
|
|
31
|
+
offMapEvent(eventName: any, id: any, nativeMapView?: any): void;
|
|
32
|
+
private checkForClickEvent;
|
|
33
|
+
private _addMarkers;
|
|
34
|
+
show(options: ShowOptions): Promise<any>;
|
|
35
|
+
hide(): Promise<void>;
|
|
36
|
+
unhide(): Promise<void>;
|
|
37
|
+
destroy(nativeMap?: any): Promise<void>;
|
|
38
|
+
onStart(nativeMap?: any): Promise<void>;
|
|
39
|
+
onResume(nativeMap?: any): Promise<void>;
|
|
40
|
+
onPause(nativeMap?: any): Promise<void>;
|
|
41
|
+
onStop(nativeMap?: any): Promise<void>;
|
|
42
|
+
onLowMemory(nativeMap?: any): Promise<void>;
|
|
43
|
+
onDestroy(nativeMap?: any): Promise<void>;
|
|
44
|
+
setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<void>;
|
|
45
|
+
getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
|
|
46
|
+
addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
|
|
47
|
+
removeImage(imageId: string, nativeMap?: any): Promise<void>;
|
|
48
|
+
addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<void>;
|
|
49
|
+
removeMarkers(ids?: any, nativeMap?: any): Promise<void>;
|
|
50
|
+
setCenter(options: SetCenterOptions, nativeMap?: any): Promise<void>;
|
|
51
|
+
getCenter(nativeMap?: any): Promise<LatLng>;
|
|
52
|
+
setZoomLevel(options: SetZoomLevelOptions, nativeMap?: any): Promise<void>;
|
|
53
|
+
getZoomLevel(nativeMap?: any): Promise<number>;
|
|
54
|
+
setTilt(options: SetTiltOptions, nativeMap?: any): Promise<void>;
|
|
55
|
+
getTilt(nativeMap?: any): Promise<number>;
|
|
56
|
+
getUserLocation(nativeMap?: any): Promise<UserLocation>;
|
|
57
|
+
_stringToCameraMode(mode: UserLocationCameraMode): any;
|
|
58
|
+
_stringToRenderMode(mode: any): any;
|
|
59
|
+
showUserLocationMarker(options: any, nativeMap?: any): Promise<void>;
|
|
60
|
+
hideUserLocationMarker(nativeMap?: any): Promise<void>;
|
|
61
|
+
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
|
|
62
|
+
forceUserLocationUpdate(location: any, nativeMap?: any): void;
|
|
63
|
+
queryRenderedFeatures(options: QueryRenderedFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
|
|
64
|
+
querySourceFeatures(sourceId: string, options?: QuerySourceFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
|
|
65
|
+
addPolygon(options: AddPolygonOptions, nativeMap?: any): Promise<void>;
|
|
66
|
+
addPolyline(options: AddPolylineOptions, nativeMap?: any): Promise<void>;
|
|
67
|
+
private removePolyById;
|
|
68
|
+
private removePolys;
|
|
69
|
+
removePolygons(ids?: any[], nativeMap?: any): Promise<void>;
|
|
70
|
+
removePolylines(ids?: any[], nativeMap?: any): Promise<void>;
|
|
71
|
+
animateCamera(options: AnimateCameraOptions, nativeMap?: any): Promise<void>;
|
|
72
|
+
setOnMapClickListener(listener: (data: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
73
|
+
setOnMapLongClickListener(listener: (data: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
74
|
+
setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
75
|
+
setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
76
|
+
setOnFlingListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
77
|
+
setOnCameraMoveListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
|
|
78
|
+
setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
79
|
+
setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
80
|
+
getViewport(nativeMap?: any): Promise<Viewport>;
|
|
81
|
+
setViewport(options: SetViewportOptions, nativeMap?: any): Promise<void>;
|
|
82
|
+
downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<void>;
|
|
83
|
+
listOfflineRegions(options?: ListOfflineRegionsOptions): Promise<OfflineRegion[]>;
|
|
84
|
+
deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
|
|
85
|
+
addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
|
|
86
|
+
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<unknown>;
|
|
87
|
+
addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
|
|
88
|
+
removeSource(id: string, nativeMap?: any): Promise<void>;
|
|
89
|
+
addLayer(style: any, belowLayerId?: string, nativeMapView?: any): Promise<void>;
|
|
90
|
+
removeLayer(id: string, nativeMapViewInstance?: any): Promise<void>;
|
|
91
|
+
addLinePoint(id: string, lnglat: any, sourceId?: string, nativeMapView?: any): Promise<void>;
|
|
92
|
+
addGeoJsonClustered(options: AddGeoJsonClusteredOptions, nativeMapViewInstance?: any): Promise<void>;
|
|
93
|
+
trackUser(options: TrackUserOptions, nativeMap?: any): Promise<void>;
|
|
94
|
+
getLayer(name: string, nativeMap?: any): Promise<LayerCommon>;
|
|
95
|
+
getLayers(nativeMap?: any): Promise<LayerCommon[]>;
|
|
96
|
+
project(data: LatLng): {
|
|
97
|
+
x: number;
|
|
98
|
+
y: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ImageSource } from '@nativescript/core';
|
|
2
|
-
import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapStyle, MapboxApi, MapboxCommon, MapboxMarker,
|
|
3
|
-
export
|
|
2
|
+
import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapStyle, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport } from './common';
|
|
3
|
+
export * from './common';
|
|
4
4
|
export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' | 'fault' | 'verbose'): void;
|
|
5
5
|
export declare class MapboxView extends MapboxViewBase {
|
|
6
6
|
private nativeMapView;
|
|
@@ -18,23 +18,6 @@ export declare class MapboxView extends MapboxViewBase {
|
|
|
18
18
|
initMap(): void;
|
|
19
19
|
onLayout(left: number, top: number, right: number, bottom: number): void;
|
|
20
20
|
}
|
|
21
|
-
export declare class CustomUserLocationAnnotationView extends MGLUserLocationAnnotationView implements MGLUserLocationAnnotationView {
|
|
22
|
-
size: number;
|
|
23
|
-
dot: CALayer;
|
|
24
|
-
arrow: CAShapeLayer;
|
|
25
|
-
private userLocationRenderMode;
|
|
26
|
-
private renderModeChanged;
|
|
27
|
-
init(): this;
|
|
28
|
-
update(): void;
|
|
29
|
-
drawTrackingLocationMarker(): void;
|
|
30
|
-
drawNonTrackingLocationMarker(): void;
|
|
31
|
-
drawTrackingDot(): void;
|
|
32
|
-
drawNonTrackingDot(): void;
|
|
33
|
-
drawArrow(): void;
|
|
34
|
-
updateHeading(): void;
|
|
35
|
-
arrowPath(): any;
|
|
36
|
-
changeUserLocationRenderMode(renderMode: any): void;
|
|
37
|
-
}
|
|
38
21
|
export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
39
22
|
private _mapboxViewInstance;
|
|
40
23
|
private eventCallbacks;
|
|
@@ -87,6 +70,7 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
87
70
|
setOnMapLongClickListener(listener: (data: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
88
71
|
setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
89
72
|
setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
|
|
73
|
+
setOnMoveEndListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
90
74
|
setOnFlingListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
91
75
|
setOnCameraMoveListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
|
|
92
76
|
setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<void>;
|
|
@@ -112,14 +96,3 @@ export declare class Mapbox extends MapboxCommon implements MapboxApi {
|
|
|
112
96
|
y: number;
|
|
113
97
|
};
|
|
114
98
|
}
|
|
115
|
-
export declare class Layer implements LayerCommon {
|
|
116
|
-
id: string;
|
|
117
|
-
private instance;
|
|
118
|
-
constructor(instance: any);
|
|
119
|
-
visibility(): boolean;
|
|
120
|
-
show(): void;
|
|
121
|
-
hide(): void;
|
|
122
|
-
getNativeInstance(): any;
|
|
123
|
-
setFilter(filter: any[]): void;
|
|
124
|
-
getFilter(): any[];
|
|
125
|
-
}
|