@maplibre/maplibre-react-native 10.0.0-beta.6 → 10.0.0-beta.7
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/lib/commonjs/MapLibreRN.js +0 -8
- package/lib/commonjs/MapLibreRN.js.map +1 -1
- package/lib/module/MapLibreRN.js +0 -1
- package/lib/module/MapLibreRN.js.map +1 -1
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -1
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
- package/lib/typescript/module/src/MapLibreRN.d.ts +0 -1
- package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapLibreRN.ts +0 -1
- package/lib/commonjs/components/Style.js +0 -266
- package/lib/commonjs/components/Style.js.map +0 -1
- package/lib/module/components/Style.js +0 -261
- package/lib/module/components/Style.js.map +0 -1
- package/lib/typescript/commonjs/src/components/Style.d.ts +0 -81
- package/lib/typescript/commonjs/src/components/Style.d.ts.map +0 -1
- package/lib/typescript/module/src/components/Style.d.ts +0 -81
- package/lib/typescript/module/src/components/Style.d.ts.map +0 -1
- package/src/components/Style.tsx +0 -371
|
@@ -28,7 +28,6 @@ var _exportNames = {
|
|
|
28
28
|
RasterLayer: true,
|
|
29
29
|
BackgroundLayer: true,
|
|
30
30
|
MarkerView: true,
|
|
31
|
-
Style: true,
|
|
32
31
|
locationManager: true,
|
|
33
32
|
offlineManager: true,
|
|
34
33
|
OfflinePack: true,
|
|
@@ -169,12 +168,6 @@ Object.defineProperty(exports, "ShapeSource", {
|
|
|
169
168
|
return _ShapeSource.default;
|
|
170
169
|
}
|
|
171
170
|
});
|
|
172
|
-
Object.defineProperty(exports, "Style", {
|
|
173
|
-
enumerable: true,
|
|
174
|
-
get: function () {
|
|
175
|
-
return _Style.default;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
171
|
Object.defineProperty(exports, "SymbolLayer", {
|
|
179
172
|
enumerable: true,
|
|
180
173
|
get: function () {
|
|
@@ -263,7 +256,6 @@ var _SymbolLayer = _interopRequireDefault(require("./components/SymbolLayer.js")
|
|
|
263
256
|
var _RasterLayer = _interopRequireDefault(require("./components/RasterLayer.js"));
|
|
264
257
|
var _BackgroundLayer = _interopRequireDefault(require("./components/BackgroundLayer.js"));
|
|
265
258
|
var _MarkerView = _interopRequireDefault(require("./components/MarkerView.js"));
|
|
266
|
-
var _Style = _interopRequireDefault(require("./components/Style.js"));
|
|
267
259
|
var _locationManager = _interopRequireDefault(require("./modules/location/locationManager.js"));
|
|
268
260
|
var _offlineManager = _interopRequireDefault(require("./modules/offline/offlineManager.js"));
|
|
269
261
|
var _OfflinePack = _interopRequireDefault(require("./modules/offline/OfflinePack.js"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MLRNModule","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Camera","_interopRequireWildcard","_MapView","_interopRequireDefault","_Light","_PointAnnotation","_Annotation","_Callout","_requestAndroidLocationPermissions","_UserLocation","_VectorSource","_ShapeSource","_RasterSource","_ImageSource","_Images","_FillLayer","_FillExtrusionLayer","_HeatmapLayer","_LineLayer","_CircleLayer","_SymbolLayer","_RasterLayer","_BackgroundLayer","_MarkerView","
|
|
1
|
+
{"version":3,"names":["_MLRNModule","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Camera","_interopRequireWildcard","_MapView","_interopRequireDefault","_Light","_PointAnnotation","_Annotation","_Callout","_requestAndroidLocationPermissions","_UserLocation","_VectorSource","_ShapeSource","_RasterSource","_ImageSource","_Images","_FillLayer","_FillExtrusionLayer","_HeatmapLayer","_LineLayer","_CircleLayer","_SymbolLayer","_RasterLayer","_BackgroundLayer","_MarkerView","_locationManager","_offlineManager","_OfflinePack","_OfflineCreatePackOptions","_snapshotManager","_Animated","_Logger","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t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AAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAA9B,wBAAA8B,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAtC,GAAA,CAAAgC,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAArD,MAAA,CAAAS,cAAA,IAAAT,MAAA,CAAAsD,wBAAA,WAAAC,CAAA,IAAAZ,CAAA,oBAAAY,CAAA,OAAAlD,cAAA,CAAAC,IAAA,CAAAqC,CAAA,EAAAY,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAArD,MAAA,CAAAsD,wBAAA,CAAAX,CAAA,EAAAY,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAA7C,GAAA,IAAA6C,CAAA,CAAAC,GAAA,IAAAzD,MAAA,CAAAS,cAAA,CAAA0C,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAZ,CAAA,CAAAY,CAAA,YAAAJ,CAAA,CAAAN,OAAA,GAAAF,CAAA,EAAAM,CAAA,IAAAA,CAAA,CAAAQ,GAAA,CAAAd,CAAA,EAAAQ,CAAA,GAAAA,CAAA","ignoreList":[]}
|
package/lib/module/MapLibreRN.js
CHANGED
|
@@ -23,7 +23,6 @@ export { default as SymbolLayer } from "./components/SymbolLayer.js";
|
|
|
23
23
|
export { default as RasterLayer } from "./components/RasterLayer.js";
|
|
24
24
|
export { default as BackgroundLayer } from "./components/BackgroundLayer.js";
|
|
25
25
|
export { default as MarkerView } from "./components/MarkerView.js";
|
|
26
|
-
export { default as Style } from "./components/Style.js";
|
|
27
26
|
export { default as locationManager } from "./modules/location/locationManager.js";
|
|
28
27
|
export { default as offlineManager } from "./modules/offline/offlineManager.js";
|
|
29
28
|
export { default as OfflinePack } from "./modules/offline/OfflinePack.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","Camera","UserTrackingMode","MapView","Light","PointAnnotation","Annotation","Callout","requestAndroidLocationPermissions","UserLocation","UserLocationRenderMode","VectorSource","ShapeSource","RasterSource","ImageSource","Images","FillLayer","FillExtrusionLayer","HeatmapLayer","LineLayer","CircleLayer","SymbolLayer","RasterLayer","BackgroundLayer","MarkerView","
|
|
1
|
+
{"version":3,"names":["default","Camera","UserTrackingMode","MapView","Light","PointAnnotation","Annotation","Callout","requestAndroidLocationPermissions","UserLocation","UserLocationRenderMode","VectorSource","ShapeSource","RasterSource","ImageSource","Images","FillLayer","FillExtrusionLayer","HeatmapLayer","LineLayer","CircleLayer","SymbolLayer","RasterLayer","BackgroundLayer","MarkerView","locationManager","offlineManager","OfflinePack","OfflineCreatePackOptions","snapshotManager","Animated","Logger"],"sourceRoot":"../../src","sources":["MapLibreRN.ts"],"mappings":";;AAAA,cAAc,iBAAc;AAC5B,SACEA,OAAO,IAAIC,MAAM,EACjBC,gBAAgB,QAKX,wBAAqB;AAC5B,SACEF,OAAO,IAAIG,OAAO,QAGb,yBAAsB;AAC7B,SAASH,OAAO,IAAII,KAAK,QAAQ,uBAAoB;AACrD,SAASJ,OAAO,IAAIK,eAAe,QAAQ,iCAA8B;AAEzE,SAASL,OAAO,IAAIM,UAAU,QAAQ,4BAAyB;AAC/D,SAASN,OAAO,IAAIO,OAAO,QAAQ,yBAAsB;AACzD,SAASC,iCAAiC,QAAQ,wCAAqC;AACvF,SACER,OAAO,IAAIS,YAAY,EACvBC,sBAAsB,QACjB,8BAA2B;AAElC,SAASV,OAAO,IAAIW,YAAY,QAAQ,8BAA2B;AACnE,SAASX,OAAO,IAAIY,WAAW,QAAQ,6BAA0B;AAEjE,SAASZ,OAAO,IAAIa,YAAY,QAAQ,8BAA2B;AACnE,SAASb,OAAO,IAAIc,WAAW,QAAQ,6BAA0B;AACjE,SAASd,OAAO,IAAIe,MAAM,QAAQ,wBAAqB;AACvD,SAASf,OAAO,IAAIgB,SAAS,QAAQ,2BAAwB;AAC7D,SAAShB,OAAO,IAAIiB,kBAAkB,QAAQ,oCAAiC;AAC/E,SAASjB,OAAO,IAAIkB,YAAY,QAAQ,8BAA2B;AACnE,SAASlB,OAAO,IAAImB,SAAS,QAAQ,2BAAwB;AAC7D,SAASnB,OAAO,IAAIoB,WAAW,QAAQ,6BAA0B;AACjE,SAASpB,OAAO,IAAIqB,WAAW,QAAQ,6BAA0B;AACjE,SAASrB,OAAO,IAAIsB,WAAW,QAAQ,6BAA0B;AACjE,SAAStB,OAAO,IAAIuB,eAAe,QAAQ,iCAA8B;AACzE,SAASvB,OAAO,IAAIwB,UAAU,QAAQ,4BAAyB;AAE/D,SACExB,OAAO,IAAIyB,eAAe,QAErB,uCAAoC;AAC3C,SAASzB,OAAO,IAAI0B,cAAc,QAAQ,qCAAkC;AAG5E,SAAS1B,OAAO,IAAI2B,WAAW,QAAQ,kCAA+B;AACtE,SAAS3B,OAAO,IAAI4B,wBAAwB,QAAQ,+CAA4C;AAChG,SAAS5B,OAAO,IAAI6B,eAAe,QAAQ,uCAAoC;AAK/E,SAAS7B,OAAO,IAAI8B,QAAQ,QAAQ,8BAA2B;AAC/D,SAAS9B,OAAO,IAAI+B,MAAM,QAAuB,mBAAgB","ignoreList":[]}
|
|
@@ -24,7 +24,6 @@ export { default as SymbolLayer } from "./components/SymbolLayer";
|
|
|
24
24
|
export { default as RasterLayer } from "./components/RasterLayer";
|
|
25
25
|
export { default as BackgroundLayer } from "./components/BackgroundLayer";
|
|
26
26
|
export { default as MarkerView } from "./components/MarkerView";
|
|
27
|
-
export { default as Style } from "./components/Style";
|
|
28
27
|
export { default as locationManager, type Location, } from "./modules/location/locationManager";
|
|
29
28
|
export { default as offlineManager } from "./modules/offline/offlineManager";
|
|
30
29
|
export type { OfflinePackError } from "./modules/offline/offlineManager";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLibreRN.d.ts","sourceRoot":"","sources":["../../../../src/MapLibreRN.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAA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AoC,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAC7E,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EACV,mBAAmB,IAAI,cAAc,EACrC,mBAAmB,IAAI,cAAc,EACrC,qBAAqB,IAAI,gBAAgB,EACzC,qBAAqB,IAAI,gBAAgB,EACzC,sBAAsB,IAAI,iBAAiB,EAC3C,4BAA4B,IAAI,uBAAuB,EACvD,qBAAqB,IAAI,gBAAgB,EACzC,wBAAwB,IAAI,mBAAmB,EAC/C,yBAAyB,IAAI,oBAAoB,EACjD,oBAAoB,IAAI,eAAe,GACxC,MAAM,0BAA0B,CAAC"}
|
|
@@ -24,7 +24,6 @@ export { default as SymbolLayer } from "./components/SymbolLayer";
|
|
|
24
24
|
export { default as RasterLayer } from "./components/RasterLayer";
|
|
25
25
|
export { default as BackgroundLayer } from "./components/BackgroundLayer";
|
|
26
26
|
export { default as MarkerView } from "./components/MarkerView";
|
|
27
|
-
export { default as Style } from "./components/Style";
|
|
28
27
|
export { default as locationManager, type Location, } from "./modules/location/locationManager";
|
|
29
28
|
export { default as offlineManager } from "./modules/offline/offlineManager";
|
|
30
29
|
export type { OfflinePackError } from "./modules/offline/offlineManager";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLibreRN.d.ts","sourceRoot":"","sources":["../../../../src/MapLibreRN.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAA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K,QAAQ,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAC7E,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAChF,YAAY,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EACV,mBAAmB,IAAI,cAAc,EACrC,mBAAmB,IAAI,cAAc,EACrC,qBAAqB,IAAI,gBAAgB,EACzC,qBAAqB,IAAI,gBAAgB,EACzC,sBAAsB,IAAI,iBAAiB,EAC3C,4BAA4B,IAAI,uBAAuB,EACvD,qBAAqB,IAAI,gBAAgB,EACzC,wBAAwB,IAAI,mBAAmB,EAC/C,yBAAyB,IAAI,oBAAoB,EACjD,oBAAoB,IAAI,eAAe,GACxC,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplibre/maplibre-react-native",
|
|
3
3
|
"description": "React Native library for creating maps with MapLibre Native for Android & iOS",
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.7",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": true
|
package/src/MapLibreRN.ts
CHANGED
|
@@ -38,7 +38,6 @@ export { default as SymbolLayer } from "./components/SymbolLayer";
|
|
|
38
38
|
export { default as RasterLayer } from "./components/RasterLayer";
|
|
39
39
|
export { default as BackgroundLayer } from "./components/BackgroundLayer";
|
|
40
40
|
export { default as MarkerView } from "./components/MarkerView";
|
|
41
|
-
export { default as Style } from "./components/Style";
|
|
42
41
|
|
|
43
42
|
export {
|
|
44
43
|
default as locationManager,
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _BackgroundLayer = _interopRequireDefault(require("./BackgroundLayer.js"));
|
|
9
|
-
var _CircleLayer = _interopRequireDefault(require("./CircleLayer.js"));
|
|
10
|
-
var _FillExtrusionLayer = _interopRequireDefault(require("./FillExtrusionLayer.js"));
|
|
11
|
-
var _FillLayer = _interopRequireDefault(require("./FillLayer.js"));
|
|
12
|
-
var _HeatmapLayer = _interopRequireDefault(require("./HeatmapLayer.js"));
|
|
13
|
-
var _ImageSource = _interopRequireDefault(require("./ImageSource.js"));
|
|
14
|
-
var _LineLayer = _interopRequireDefault(require("./LineLayer.js"));
|
|
15
|
-
var _RasterLayer = _interopRequireDefault(require("./RasterLayer.js"));
|
|
16
|
-
var _RasterSource = _interopRequireDefault(require("./RasterSource.js"));
|
|
17
|
-
var _ShapeSource = _interopRequireDefault(require("./ShapeSource.js"));
|
|
18
|
-
var _SymbolLayer = _interopRequireDefault(require("./SymbolLayer.js"));
|
|
19
|
-
var _VectorSource = _interopRequireDefault(require("./VectorSource.js"));
|
|
20
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
-
function toCamelCase(s) {
|
|
23
|
-
return s.replace(/([-_][a-z])/gi, $1 => {
|
|
24
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Patches the Mapbox Style Specification keys into the style props attributes:
|
|
29
|
-
// icon-allow-overlap -> iconAllowOverlap
|
|
30
|
-
function toCamelCaseKeys(oldObj) {
|
|
31
|
-
if (!oldObj) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
const newObj = {};
|
|
35
|
-
Object.keys(oldObj).forEach(key => {
|
|
36
|
-
const value = oldObj[key];
|
|
37
|
-
if (key.includes("-")) {
|
|
38
|
-
newObj[toCamelCase(key)] = value;
|
|
39
|
-
} else {
|
|
40
|
-
newObj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return newObj;
|
|
44
|
-
}
|
|
45
|
-
function getLayerComponentType(layer) {
|
|
46
|
-
const {
|
|
47
|
-
type
|
|
48
|
-
} = layer;
|
|
49
|
-
switch (type) {
|
|
50
|
-
case "circle":
|
|
51
|
-
return _CircleLayer.default;
|
|
52
|
-
case "symbol":
|
|
53
|
-
return _SymbolLayer.default;
|
|
54
|
-
case "raster":
|
|
55
|
-
return _RasterLayer.default;
|
|
56
|
-
case "line":
|
|
57
|
-
return _LineLayer.default;
|
|
58
|
-
case "fill":
|
|
59
|
-
return _FillLayer.default;
|
|
60
|
-
case "fill-extrusion":
|
|
61
|
-
return _FillExtrusionLayer.default;
|
|
62
|
-
case "background":
|
|
63
|
-
return _BackgroundLayer.default;
|
|
64
|
-
case "heatmap":
|
|
65
|
-
return _HeatmapLayer.default;
|
|
66
|
-
}
|
|
67
|
-
console.warn(`Mapbox layer type '${type}' is not supported/`);
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
function asLayerComponent(layer) {
|
|
71
|
-
const LayerComponent = getLayerComponentType(layer);
|
|
72
|
-
if (!LayerComponent) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const style = {
|
|
76
|
-
...toCamelCaseKeys(layer.paint),
|
|
77
|
-
...toCamelCaseKeys(layer.layout)
|
|
78
|
-
};
|
|
79
|
-
const layerProps = {};
|
|
80
|
-
if (layer.source) {
|
|
81
|
-
layerProps.sourceID = layer.source;
|
|
82
|
-
}
|
|
83
|
-
if (layer["source-layer"]) {
|
|
84
|
-
layerProps.sourceLayerID = layer["source-layer"];
|
|
85
|
-
}
|
|
86
|
-
if (layer.minzoom) {
|
|
87
|
-
layerProps.minZoomLevel = layer.minzoom;
|
|
88
|
-
}
|
|
89
|
-
if (layer.maxzoom) {
|
|
90
|
-
layerProps.maxZoomLevel = layer.maxzoom;
|
|
91
|
-
}
|
|
92
|
-
if (layer.filter) {
|
|
93
|
-
layerProps.filter = layer.filter;
|
|
94
|
-
}
|
|
95
|
-
if (Object.keys(style).length) {
|
|
96
|
-
layerProps.style = style;
|
|
97
|
-
}
|
|
98
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LayerComponent, {
|
|
99
|
-
id: layer.id,
|
|
100
|
-
...layerProps
|
|
101
|
-
}, layer.id);
|
|
102
|
-
}
|
|
103
|
-
function getTileSourceProps(source) {
|
|
104
|
-
const sourceProps = {};
|
|
105
|
-
if (source.url) {
|
|
106
|
-
sourceProps.url = source.url;
|
|
107
|
-
}
|
|
108
|
-
if (source.tiles) {
|
|
109
|
-
sourceProps.tileUrlTemplates = source.tiles;
|
|
110
|
-
}
|
|
111
|
-
if (source.minzoom !== undefined) {
|
|
112
|
-
sourceProps.minZoomLevel = source.minzoom;
|
|
113
|
-
}
|
|
114
|
-
if (source.maxzoom !== undefined) {
|
|
115
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
116
|
-
}
|
|
117
|
-
if (source.attribution) {
|
|
118
|
-
sourceProps.attribution = source.attribution;
|
|
119
|
-
}
|
|
120
|
-
if (source.scheme && source.scheme === "tms") {
|
|
121
|
-
sourceProps.tms = true;
|
|
122
|
-
}
|
|
123
|
-
return sourceProps;
|
|
124
|
-
}
|
|
125
|
-
function getVectorSource(id, source) {
|
|
126
|
-
const sourceProps = {
|
|
127
|
-
...getTileSourceProps(source)
|
|
128
|
-
};
|
|
129
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VectorSource.default, {
|
|
130
|
-
id: id,
|
|
131
|
-
...sourceProps
|
|
132
|
-
}, id);
|
|
133
|
-
}
|
|
134
|
-
function getRasterSource(id, source) {
|
|
135
|
-
const sourceProps = {
|
|
136
|
-
...getTileSourceProps(source)
|
|
137
|
-
};
|
|
138
|
-
if (source.tileSize) {
|
|
139
|
-
sourceProps.tileSize = source.tileSize;
|
|
140
|
-
}
|
|
141
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RasterSource.default, {
|
|
142
|
-
id: id,
|
|
143
|
-
...sourceProps
|
|
144
|
-
}, id);
|
|
145
|
-
}
|
|
146
|
-
function getImageSource(id, source) {
|
|
147
|
-
const sourceProps = {
|
|
148
|
-
url: source.url,
|
|
149
|
-
coordinates: source.coordinates
|
|
150
|
-
};
|
|
151
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageSource.default, {
|
|
152
|
-
id: id,
|
|
153
|
-
...sourceProps
|
|
154
|
-
}, id);
|
|
155
|
-
}
|
|
156
|
-
function getShapeSource(id, source) {
|
|
157
|
-
const sourceProps = {};
|
|
158
|
-
if (source.data && typeof source.data === "string") {
|
|
159
|
-
sourceProps.url = source.data;
|
|
160
|
-
} else if (source.data && typeof source.data === "object") {
|
|
161
|
-
sourceProps.shape = source.data;
|
|
162
|
-
}
|
|
163
|
-
if (source.cluster !== undefined) {
|
|
164
|
-
sourceProps.cluster = source.cluster;
|
|
165
|
-
}
|
|
166
|
-
if (source.clusterRadius !== undefined) {
|
|
167
|
-
sourceProps.clusterRadius = source.clusterRadius;
|
|
168
|
-
}
|
|
169
|
-
if (source.maxzoom !== undefined) {
|
|
170
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
171
|
-
}
|
|
172
|
-
if (source.clusterMaxZoom !== undefined) {
|
|
173
|
-
sourceProps.clusterMaxZoomLevel = source.clusterMaxZoom;
|
|
174
|
-
}
|
|
175
|
-
if (source.clusterProperties !== undefined) {
|
|
176
|
-
sourceProps.clusterProperties = source.clusterProperties;
|
|
177
|
-
}
|
|
178
|
-
if (source.buffer !== undefined) {
|
|
179
|
-
sourceProps.buffer = source.buffer;
|
|
180
|
-
}
|
|
181
|
-
if (source.tolerance !== undefined) {
|
|
182
|
-
sourceProps.tolerance = source.tolerance;
|
|
183
|
-
}
|
|
184
|
-
if (source.lineMetrics !== undefined) {
|
|
185
|
-
sourceProps.lineMetrics = source.lineMetrics;
|
|
186
|
-
}
|
|
187
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ShapeSource.default, {
|
|
188
|
-
id: id,
|
|
189
|
-
...sourceProps
|
|
190
|
-
}, id);
|
|
191
|
-
}
|
|
192
|
-
function asSourceComponent(id, source) {
|
|
193
|
-
switch (source.type) {
|
|
194
|
-
case "vector":
|
|
195
|
-
return getVectorSource(id, source);
|
|
196
|
-
case "raster":
|
|
197
|
-
return getRasterSource(id, source);
|
|
198
|
-
case "image":
|
|
199
|
-
return getImageSource(id, source);
|
|
200
|
-
case "geojson":
|
|
201
|
-
return getShapeSource(id, source);
|
|
202
|
-
}
|
|
203
|
-
console.warn(`MapLibre source type '${source.type}' is not supported`);
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
208
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
209
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
210
|
-
*
|
|
211
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
212
|
-
*/
|
|
213
|
-
const Style = props => {
|
|
214
|
-
const [fetchedJson, setFetchedJson] = (0, _react.useState)({});
|
|
215
|
-
const json = typeof props.json === "object" ? props.json : fetchedJson;
|
|
216
|
-
|
|
217
|
-
// Fetch style when props.json is a URL
|
|
218
|
-
(0, _react.useEffect)(() => {
|
|
219
|
-
const abortController = new AbortController();
|
|
220
|
-
const fetchStyleJson = async url => {
|
|
221
|
-
try {
|
|
222
|
-
const response = await fetch(url, {
|
|
223
|
-
signal: abortController.signal
|
|
224
|
-
});
|
|
225
|
-
const responseJson = await response.json();
|
|
226
|
-
setFetchedJson(responseJson);
|
|
227
|
-
} catch (error) {
|
|
228
|
-
const e = error;
|
|
229
|
-
if (e.name === "AbortError") {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
throw e;
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
if (typeof props.json === "string") {
|
|
236
|
-
fetchStyleJson(props.json);
|
|
237
|
-
}
|
|
238
|
-
return function cleanup() {
|
|
239
|
-
abortController.abort();
|
|
240
|
-
};
|
|
241
|
-
}, [props.json]);
|
|
242
|
-
|
|
243
|
-
// Extract layer components from json
|
|
244
|
-
const layerComponents = (0, _react.useMemo)(() => {
|
|
245
|
-
if (!json.layers) {
|
|
246
|
-
return [];
|
|
247
|
-
}
|
|
248
|
-
return json.layers.map(asLayerComponent).filter(x => !!x);
|
|
249
|
-
}, [json.layers]);
|
|
250
|
-
|
|
251
|
-
// Extract source components from json
|
|
252
|
-
const sourceComponents = (0, _react.useMemo)(() => {
|
|
253
|
-
const {
|
|
254
|
-
sources
|
|
255
|
-
} = json;
|
|
256
|
-
if (!sources || !Object.keys(sources)) {
|
|
257
|
-
return [];
|
|
258
|
-
}
|
|
259
|
-
return Object.entries(sources).map(([id, source]) => asSourceComponent(id, source)).filter(x => !!x);
|
|
260
|
-
}, [json]);
|
|
261
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
262
|
-
children: [sourceComponents, layerComponents]
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
var _default = exports.default = Style;
|
|
266
|
-
//# sourceMappingURL=Style.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_BackgroundLayer","_interopRequireDefault","_CircleLayer","_FillExtrusionLayer","_FillLayer","_HeatmapLayer","_ImageSource","_LineLayer","_RasterLayer","_RasterSource","_ShapeSource","_SymbolLayer","_VectorSource","_jsxRuntime","e","__esModule","default","toCamelCase","s","replace","$1","toUpperCase","toCamelCaseKeys","oldObj","newObj","Object","keys","forEach","key","value","includes","getLayerComponentType","layer","type","CircleLayer","SymbolLayer","RasterLayer","LineLayer","FillLayer","FillExtrusionLayer","BackgroundLayer","HeatmapLayer","console","warn","asLayerComponent","LayerComponent","style","paint","layout","layerProps","source","sourceID","sourceLayerID","minzoom","minZoomLevel","maxzoom","maxZoomLevel","filter","length","jsx","id","getTileSourceProps","sourceProps","url","tiles","tileUrlTemplates","undefined","attribution","scheme","tms","getVectorSource","getRasterSource","tileSize","getImageSource","coordinates","getShapeSource","data","shape","cluster","clusterRadius","clusterMaxZoom","clusterMaxZoomLevel","clusterProperties","buffer","tolerance","lineMetrics","asSourceComponent","Style","props","fetchedJson","setFetchedJson","useState","json","useEffect","abortController","AbortController","fetchStyleJson","response","fetch","signal","responseJson","error","name","cleanup","abort","layerComponents","useMemo","layers","map","x","sourceComponents","sources","entries","jsxs","Fragment","children","_default","exports"],"sourceRoot":"../../../src","sources":["components/Style.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAGA,IAAAK,UAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,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-
import BackgroundLayer from "./BackgroundLayer.js";
|
|
5
|
-
import CircleLayer from "./CircleLayer.js";
|
|
6
|
-
import FillExtrusionLayer from "./FillExtrusionLayer.js";
|
|
7
|
-
import FillLayer from "./FillLayer.js";
|
|
8
|
-
import HeatmapLayer from "./HeatmapLayer.js";
|
|
9
|
-
import ImageSource from "./ImageSource.js";
|
|
10
|
-
import LineLayer from "./LineLayer.js";
|
|
11
|
-
import RasterLayer from "./RasterLayer.js";
|
|
12
|
-
import RasterSource from "./RasterSource.js";
|
|
13
|
-
import ShapeSource from "./ShapeSource.js";
|
|
14
|
-
import SymbolLayer from "./SymbolLayer.js";
|
|
15
|
-
import VectorSource from "./VectorSource.js";
|
|
16
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
function toCamelCase(s) {
|
|
18
|
-
return s.replace(/([-_][a-z])/gi, $1 => {
|
|
19
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Patches the Mapbox Style Specification keys into the style props attributes:
|
|
24
|
-
// icon-allow-overlap -> iconAllowOverlap
|
|
25
|
-
function toCamelCaseKeys(oldObj) {
|
|
26
|
-
if (!oldObj) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
const newObj = {};
|
|
30
|
-
Object.keys(oldObj).forEach(key => {
|
|
31
|
-
const value = oldObj[key];
|
|
32
|
-
if (key.includes("-")) {
|
|
33
|
-
newObj[toCamelCase(key)] = value;
|
|
34
|
-
} else {
|
|
35
|
-
newObj[key] = value;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return newObj;
|
|
39
|
-
}
|
|
40
|
-
function getLayerComponentType(layer) {
|
|
41
|
-
const {
|
|
42
|
-
type
|
|
43
|
-
} = layer;
|
|
44
|
-
switch (type) {
|
|
45
|
-
case "circle":
|
|
46
|
-
return CircleLayer;
|
|
47
|
-
case "symbol":
|
|
48
|
-
return SymbolLayer;
|
|
49
|
-
case "raster":
|
|
50
|
-
return RasterLayer;
|
|
51
|
-
case "line":
|
|
52
|
-
return LineLayer;
|
|
53
|
-
case "fill":
|
|
54
|
-
return FillLayer;
|
|
55
|
-
case "fill-extrusion":
|
|
56
|
-
return FillExtrusionLayer;
|
|
57
|
-
case "background":
|
|
58
|
-
return BackgroundLayer;
|
|
59
|
-
case "heatmap":
|
|
60
|
-
return HeatmapLayer;
|
|
61
|
-
}
|
|
62
|
-
console.warn(`Mapbox layer type '${type}' is not supported/`);
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
function asLayerComponent(layer) {
|
|
66
|
-
const LayerComponent = getLayerComponentType(layer);
|
|
67
|
-
if (!LayerComponent) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
const style = {
|
|
71
|
-
...toCamelCaseKeys(layer.paint),
|
|
72
|
-
...toCamelCaseKeys(layer.layout)
|
|
73
|
-
};
|
|
74
|
-
const layerProps = {};
|
|
75
|
-
if (layer.source) {
|
|
76
|
-
layerProps.sourceID = layer.source;
|
|
77
|
-
}
|
|
78
|
-
if (layer["source-layer"]) {
|
|
79
|
-
layerProps.sourceLayerID = layer["source-layer"];
|
|
80
|
-
}
|
|
81
|
-
if (layer.minzoom) {
|
|
82
|
-
layerProps.minZoomLevel = layer.minzoom;
|
|
83
|
-
}
|
|
84
|
-
if (layer.maxzoom) {
|
|
85
|
-
layerProps.maxZoomLevel = layer.maxzoom;
|
|
86
|
-
}
|
|
87
|
-
if (layer.filter) {
|
|
88
|
-
layerProps.filter = layer.filter;
|
|
89
|
-
}
|
|
90
|
-
if (Object.keys(style).length) {
|
|
91
|
-
layerProps.style = style;
|
|
92
|
-
}
|
|
93
|
-
return /*#__PURE__*/_jsx(LayerComponent, {
|
|
94
|
-
id: layer.id,
|
|
95
|
-
...layerProps
|
|
96
|
-
}, layer.id);
|
|
97
|
-
}
|
|
98
|
-
function getTileSourceProps(source) {
|
|
99
|
-
const sourceProps = {};
|
|
100
|
-
if (source.url) {
|
|
101
|
-
sourceProps.url = source.url;
|
|
102
|
-
}
|
|
103
|
-
if (source.tiles) {
|
|
104
|
-
sourceProps.tileUrlTemplates = source.tiles;
|
|
105
|
-
}
|
|
106
|
-
if (source.minzoom !== undefined) {
|
|
107
|
-
sourceProps.minZoomLevel = source.minzoom;
|
|
108
|
-
}
|
|
109
|
-
if (source.maxzoom !== undefined) {
|
|
110
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
111
|
-
}
|
|
112
|
-
if (source.attribution) {
|
|
113
|
-
sourceProps.attribution = source.attribution;
|
|
114
|
-
}
|
|
115
|
-
if (source.scheme && source.scheme === "tms") {
|
|
116
|
-
sourceProps.tms = true;
|
|
117
|
-
}
|
|
118
|
-
return sourceProps;
|
|
119
|
-
}
|
|
120
|
-
function getVectorSource(id, source) {
|
|
121
|
-
const sourceProps = {
|
|
122
|
-
...getTileSourceProps(source)
|
|
123
|
-
};
|
|
124
|
-
return /*#__PURE__*/_jsx(VectorSource, {
|
|
125
|
-
id: id,
|
|
126
|
-
...sourceProps
|
|
127
|
-
}, id);
|
|
128
|
-
}
|
|
129
|
-
function getRasterSource(id, source) {
|
|
130
|
-
const sourceProps = {
|
|
131
|
-
...getTileSourceProps(source)
|
|
132
|
-
};
|
|
133
|
-
if (source.tileSize) {
|
|
134
|
-
sourceProps.tileSize = source.tileSize;
|
|
135
|
-
}
|
|
136
|
-
return /*#__PURE__*/_jsx(RasterSource, {
|
|
137
|
-
id: id,
|
|
138
|
-
...sourceProps
|
|
139
|
-
}, id);
|
|
140
|
-
}
|
|
141
|
-
function getImageSource(id, source) {
|
|
142
|
-
const sourceProps = {
|
|
143
|
-
url: source.url,
|
|
144
|
-
coordinates: source.coordinates
|
|
145
|
-
};
|
|
146
|
-
return /*#__PURE__*/_jsx(ImageSource, {
|
|
147
|
-
id: id,
|
|
148
|
-
...sourceProps
|
|
149
|
-
}, id);
|
|
150
|
-
}
|
|
151
|
-
function getShapeSource(id, source) {
|
|
152
|
-
const sourceProps = {};
|
|
153
|
-
if (source.data && typeof source.data === "string") {
|
|
154
|
-
sourceProps.url = source.data;
|
|
155
|
-
} else if (source.data && typeof source.data === "object") {
|
|
156
|
-
sourceProps.shape = source.data;
|
|
157
|
-
}
|
|
158
|
-
if (source.cluster !== undefined) {
|
|
159
|
-
sourceProps.cluster = source.cluster;
|
|
160
|
-
}
|
|
161
|
-
if (source.clusterRadius !== undefined) {
|
|
162
|
-
sourceProps.clusterRadius = source.clusterRadius;
|
|
163
|
-
}
|
|
164
|
-
if (source.maxzoom !== undefined) {
|
|
165
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
166
|
-
}
|
|
167
|
-
if (source.clusterMaxZoom !== undefined) {
|
|
168
|
-
sourceProps.clusterMaxZoomLevel = source.clusterMaxZoom;
|
|
169
|
-
}
|
|
170
|
-
if (source.clusterProperties !== undefined) {
|
|
171
|
-
sourceProps.clusterProperties = source.clusterProperties;
|
|
172
|
-
}
|
|
173
|
-
if (source.buffer !== undefined) {
|
|
174
|
-
sourceProps.buffer = source.buffer;
|
|
175
|
-
}
|
|
176
|
-
if (source.tolerance !== undefined) {
|
|
177
|
-
sourceProps.tolerance = source.tolerance;
|
|
178
|
-
}
|
|
179
|
-
if (source.lineMetrics !== undefined) {
|
|
180
|
-
sourceProps.lineMetrics = source.lineMetrics;
|
|
181
|
-
}
|
|
182
|
-
return /*#__PURE__*/_jsx(ShapeSource, {
|
|
183
|
-
id: id,
|
|
184
|
-
...sourceProps
|
|
185
|
-
}, id);
|
|
186
|
-
}
|
|
187
|
-
function asSourceComponent(id, source) {
|
|
188
|
-
switch (source.type) {
|
|
189
|
-
case "vector":
|
|
190
|
-
return getVectorSource(id, source);
|
|
191
|
-
case "raster":
|
|
192
|
-
return getRasterSource(id, source);
|
|
193
|
-
case "image":
|
|
194
|
-
return getImageSource(id, source);
|
|
195
|
-
case "geojson":
|
|
196
|
-
return getShapeSource(id, source);
|
|
197
|
-
}
|
|
198
|
-
console.warn(`MapLibre source type '${source.type}' is not supported`);
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
203
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
204
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
205
|
-
*
|
|
206
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
207
|
-
*/
|
|
208
|
-
const Style = props => {
|
|
209
|
-
const [fetchedJson, setFetchedJson] = useState({});
|
|
210
|
-
const json = typeof props.json === "object" ? props.json : fetchedJson;
|
|
211
|
-
|
|
212
|
-
// Fetch style when props.json is a URL
|
|
213
|
-
useEffect(() => {
|
|
214
|
-
const abortController = new AbortController();
|
|
215
|
-
const fetchStyleJson = async url => {
|
|
216
|
-
try {
|
|
217
|
-
const response = await fetch(url, {
|
|
218
|
-
signal: abortController.signal
|
|
219
|
-
});
|
|
220
|
-
const responseJson = await response.json();
|
|
221
|
-
setFetchedJson(responseJson);
|
|
222
|
-
} catch (error) {
|
|
223
|
-
const e = error;
|
|
224
|
-
if (e.name === "AbortError") {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
throw e;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
if (typeof props.json === "string") {
|
|
231
|
-
fetchStyleJson(props.json);
|
|
232
|
-
}
|
|
233
|
-
return function cleanup() {
|
|
234
|
-
abortController.abort();
|
|
235
|
-
};
|
|
236
|
-
}, [props.json]);
|
|
237
|
-
|
|
238
|
-
// Extract layer components from json
|
|
239
|
-
const layerComponents = useMemo(() => {
|
|
240
|
-
if (!json.layers) {
|
|
241
|
-
return [];
|
|
242
|
-
}
|
|
243
|
-
return json.layers.map(asLayerComponent).filter(x => !!x);
|
|
244
|
-
}, [json.layers]);
|
|
245
|
-
|
|
246
|
-
// Extract source components from json
|
|
247
|
-
const sourceComponents = useMemo(() => {
|
|
248
|
-
const {
|
|
249
|
-
sources
|
|
250
|
-
} = json;
|
|
251
|
-
if (!sources || !Object.keys(sources)) {
|
|
252
|
-
return [];
|
|
253
|
-
}
|
|
254
|
-
return Object.entries(sources).map(([id, source]) => asSourceComponent(id, source)).filter(x => !!x);
|
|
255
|
-
}, [json]);
|
|
256
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
257
|
-
children: [sourceComponents, layerComponents]
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
export default Style;
|
|
261
|
-
//# sourceMappingURL=Style.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","useEffect","BackgroundLayer","CircleLayer","FillExtrusionLayer","FillLayer","HeatmapLayer","ImageSource","LineLayer","RasterLayer","RasterSource","ShapeSource","SymbolLayer","VectorSource","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","toCamelCase","s","replace","$1","toUpperCase","toCamelCaseKeys","oldObj","newObj","Object","keys","forEach","key","value","includes","getLayerComponentType","layer","type","console","warn","asLayerComponent","LayerComponent","style","paint","layout","layerProps","source","sourceID","sourceLayerID","minzoom","minZoomLevel","maxzoom","maxZoomLevel","filter","length","id","getTileSourceProps","sourceProps","url","tiles","tileUrlTemplates","undefined","attribution","scheme","tms","getVectorSource","getRasterSource","tileSize","getImageSource","coordinates","getShapeSource","data","shape","cluster","clusterRadius","clusterMaxZoom","clusterMaxZoomLevel","clusterProperties","buffer","tolerance","lineMetrics","asSourceComponent","Style","props","fetchedJson","setFetchedJson","json","abortController","AbortController","fetchStyleJson","response","fetch","signal","responseJson","error","e","name","cleanup","abort","layerComponents","layers","map","x","sourceComponents","sources","entries","children"],"sourceRoot":"../../../src","sources":["components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;EACA,MAAMa,eAAe,GAAGnG,OAAO,CAAC,MAAM;IACpC,IAAI,CAACsF,IAAI,CAACc,MAAM,EAAE;MAChB,OAAO,EAAE;IACX;IACA,OAAOd,IAAI,CAACc,MAAM,CACfC,GAAG,CAAC7D,gBAAgB,CAAC,CACrBa,MAAM,CAAEiD,CAAsB,IAAK,CAAC,CAACA,CAAC,CAAC;EAC5C,CAAC,EAAE,CAAChB,IAAI,CAACc,MAAM,CAAC,CAAC;;EAEjB;EACA,MAAMG,gBAAgB,GAAGvG,OAAO,CAAC,MAAM;IACrC,MAAM;MAAEwG;IAAQ,CAAC,GAAGlB,IAAI;IACxB,IAAI,CAACkB,OAAO,IAAI,CAAC3E,MAAM,CAACC,IAAI,CAAC0E,OAAO,CAAC,EAAE;MACrC,OAAO,EAAE;IACX;IACA,OAAO3E,MAAM,CAAC4E,OAAO,CAACD,OAAO,CAAC,CAC3BH,GAAG,CAAC,CAAC,CAAC9C,EAAE,EAAET,MAAM,CAAC,KAAKmC,iBAAiB,CAAC1B,EAAE,EAAET,MAAM,CAAC,CAAC,CACpDO,MAAM,CAAEiD,CAAC,IAAK,CAAC,CAACA,CAAC,CAAC;EACvB,CAAC,EAAE,CAAChB,IAAI,CAAC,CAAC;EAEV,oBACElE,KAAA,CAAAF,SAAA;IAAAwF,QAAA,GACGH,gBAAgB,EAChBJ,eAAe;EAAA,CAChB,CAAC;AAEP,CAAC;AAED,eAAejB,KAAK","ignoreList":[]}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from "react";
|
|
2
|
-
import { type ExpressionField, type FilterExpression } from "../utils/MapLibreRNStyles";
|
|
3
|
-
interface MapLibreJSONLayer {
|
|
4
|
-
type: string;
|
|
5
|
-
paint: {
|
|
6
|
-
[k: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
layout: {
|
|
9
|
-
[k: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
source?: string;
|
|
12
|
-
"source-layer"?: string;
|
|
13
|
-
minzoom?: number;
|
|
14
|
-
maxzoom?: number;
|
|
15
|
-
filter?: FilterExpression;
|
|
16
|
-
id: string;
|
|
17
|
-
}
|
|
18
|
-
interface MapLibreJSONSource {
|
|
19
|
-
type: string;
|
|
20
|
-
url?: string;
|
|
21
|
-
tiles?: string[];
|
|
22
|
-
minzoom?: number;
|
|
23
|
-
maxzoom?: number;
|
|
24
|
-
attribution?: string;
|
|
25
|
-
scheme?: "xyz" | "tms";
|
|
26
|
-
bounds?: number[];
|
|
27
|
-
buffer?: number;
|
|
28
|
-
tileSize?: number;
|
|
29
|
-
coordinates?: [
|
|
30
|
-
[
|
|
31
|
-
number,
|
|
32
|
-
number
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
number,
|
|
36
|
-
number
|
|
37
|
-
],
|
|
38
|
-
[
|
|
39
|
-
number,
|
|
40
|
-
number
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
number,
|
|
44
|
-
number
|
|
45
|
-
]
|
|
46
|
-
];
|
|
47
|
-
cluster?: boolean;
|
|
48
|
-
clusterMaxZoom?: number;
|
|
49
|
-
clusterMinPoints?: number;
|
|
50
|
-
clusterRadius?: number;
|
|
51
|
-
clusterProperties?: {
|
|
52
|
-
[propertyName: string]: ExpressionField;
|
|
53
|
-
};
|
|
54
|
-
data?: string | object;
|
|
55
|
-
filter?: FilterExpression;
|
|
56
|
-
generateId?: boolean;
|
|
57
|
-
lineMetrics?: boolean;
|
|
58
|
-
tolerance?: number;
|
|
59
|
-
}
|
|
60
|
-
interface MapLibreJSON {
|
|
61
|
-
layers?: MapLibreJSONLayer[];
|
|
62
|
-
sources?: {
|
|
63
|
-
[key: string]: MapLibreJSONSource;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
interface StyleProps {
|
|
67
|
-
/**
|
|
68
|
-
* A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON.
|
|
69
|
-
*/
|
|
70
|
-
json?: MapLibreJSON | URL;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
74
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
75
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
76
|
-
*
|
|
77
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
78
|
-
*/
|
|
79
|
-
declare const Style: (props: StyleProps) => ReactElement;
|
|
80
|
-
export default Style;
|
|
81
|
-
//# sourceMappingURL=Style.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Style.d.ts","sourceRoot":"","sources":["../../../../../src/components/Style.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAgBf,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAmEnC,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAChC,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;CACZ;AAwCD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM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AG,YA0DlC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from "react";
|
|
2
|
-
import { type ExpressionField, type FilterExpression } from "../utils/MapLibreRNStyles";
|
|
3
|
-
interface MapLibreJSONLayer {
|
|
4
|
-
type: string;
|
|
5
|
-
paint: {
|
|
6
|
-
[k: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
layout: {
|
|
9
|
-
[k: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
source?: string;
|
|
12
|
-
"source-layer"?: string;
|
|
13
|
-
minzoom?: number;
|
|
14
|
-
maxzoom?: number;
|
|
15
|
-
filter?: FilterExpression;
|
|
16
|
-
id: string;
|
|
17
|
-
}
|
|
18
|
-
interface MapLibreJSONSource {
|
|
19
|
-
type: string;
|
|
20
|
-
url?: string;
|
|
21
|
-
tiles?: string[];
|
|
22
|
-
minzoom?: number;
|
|
23
|
-
maxzoom?: number;
|
|
24
|
-
attribution?: string;
|
|
25
|
-
scheme?: "xyz" | "tms";
|
|
26
|
-
bounds?: number[];
|
|
27
|
-
buffer?: number;
|
|
28
|
-
tileSize?: number;
|
|
29
|
-
coordinates?: [
|
|
30
|
-
[
|
|
31
|
-
number,
|
|
32
|
-
number
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
number,
|
|
36
|
-
number
|
|
37
|
-
],
|
|
38
|
-
[
|
|
39
|
-
number,
|
|
40
|
-
number
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
number,
|
|
44
|
-
number
|
|
45
|
-
]
|
|
46
|
-
];
|
|
47
|
-
cluster?: boolean;
|
|
48
|
-
clusterMaxZoom?: number;
|
|
49
|
-
clusterMinPoints?: number;
|
|
50
|
-
clusterRadius?: number;
|
|
51
|
-
clusterProperties?: {
|
|
52
|
-
[propertyName: string]: ExpressionField;
|
|
53
|
-
};
|
|
54
|
-
data?: string | object;
|
|
55
|
-
filter?: FilterExpression;
|
|
56
|
-
generateId?: boolean;
|
|
57
|
-
lineMetrics?: boolean;
|
|
58
|
-
tolerance?: number;
|
|
59
|
-
}
|
|
60
|
-
interface MapLibreJSON {
|
|
61
|
-
layers?: MapLibreJSONLayer[];
|
|
62
|
-
sources?: {
|
|
63
|
-
[key: string]: MapLibreJSONSource;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
interface StyleProps {
|
|
67
|
-
/**
|
|
68
|
-
* A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON.
|
|
69
|
-
*/
|
|
70
|
-
json?: MapLibreJSON | URL;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
74
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
75
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
76
|
-
*
|
|
77
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
78
|
-
*/
|
|
79
|
-
declare const Style: (props: StyleProps) => ReactElement;
|
|
80
|
-
export default Style;
|
|
81
|
-
//# sourceMappingURL=Style.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Style.d.ts","sourceRoot":"","sources":["../../../../../src/components/Style.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAgBf,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAmEnC,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAChC,MA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B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0HD,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAE,CAAC;CACjD;AAED,UAAU,UAAU;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,QAAA,MAAM,KAAK,UAAW,UAAU,KAAG,YA0DlC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/src/components/Style.tsx
DELETED
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useMemo,
|
|
3
|
-
useState,
|
|
4
|
-
useEffect,
|
|
5
|
-
type ReactElement,
|
|
6
|
-
type ComponentType,
|
|
7
|
-
} from "react";
|
|
8
|
-
|
|
9
|
-
import BackgroundLayer, { type BackgroundLayerProps } from "./BackgroundLayer";
|
|
10
|
-
import CircleLayer, { type CircleLayerProps } from "./CircleLayer";
|
|
11
|
-
import FillExtrusionLayer, {
|
|
12
|
-
type FillExtrusionLayerProps,
|
|
13
|
-
} from "./FillExtrusionLayer";
|
|
14
|
-
import FillLayer, { type FillLayerProps } from "./FillLayer";
|
|
15
|
-
import HeatmapLayer, { type HeatmapLayerProps } from "./HeatmapLayer";
|
|
16
|
-
import ImageSource from "./ImageSource";
|
|
17
|
-
import LineLayer, { type LineLayerProps } from "./LineLayer";
|
|
18
|
-
import RasterLayer, { type RasterLayerProps } from "./RasterLayer";
|
|
19
|
-
import RasterSource from "./RasterSource";
|
|
20
|
-
import ShapeSource from "./ShapeSource";
|
|
21
|
-
import SymbolLayer, { type SymbolLayerProps } from "./SymbolLayer";
|
|
22
|
-
import VectorSource from "./VectorSource";
|
|
23
|
-
import {
|
|
24
|
-
type ExpressionField,
|
|
25
|
-
type FilterExpression,
|
|
26
|
-
} from "../utils/MapLibreRNStyles";
|
|
27
|
-
|
|
28
|
-
function toCamelCase(s: string): string {
|
|
29
|
-
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
30
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Patches the Mapbox Style Specification keys into the style props attributes:
|
|
35
|
-
// icon-allow-overlap -> iconAllowOverlap
|
|
36
|
-
function toCamelCaseKeys(
|
|
37
|
-
oldObj: Record<string, unknown>,
|
|
38
|
-
): Record<string, unknown> {
|
|
39
|
-
if (!oldObj) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
const newObj: Record<string, unknown> = {};
|
|
43
|
-
Object.keys(oldObj).forEach((key) => {
|
|
44
|
-
const value = oldObj[key];
|
|
45
|
-
if (key.includes("-")) {
|
|
46
|
-
newObj[toCamelCase(key)] = value;
|
|
47
|
-
} else {
|
|
48
|
-
newObj[key] = value;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return newObj;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type LayerProps =
|
|
55
|
-
| CircleLayerProps
|
|
56
|
-
| SymbolLayerProps
|
|
57
|
-
| RasterLayerProps
|
|
58
|
-
| LineLayerProps
|
|
59
|
-
| FillLayerProps
|
|
60
|
-
| FillExtrusionLayerProps
|
|
61
|
-
| BackgroundLayerProps
|
|
62
|
-
| HeatmapLayerProps;
|
|
63
|
-
|
|
64
|
-
function getLayerComponentType(
|
|
65
|
-
layer: MapLibreJSONLayer,
|
|
66
|
-
): ComponentType<LayerProps> | null {
|
|
67
|
-
const { type } = layer;
|
|
68
|
-
|
|
69
|
-
switch (type) {
|
|
70
|
-
case "circle":
|
|
71
|
-
return CircleLayer;
|
|
72
|
-
case "symbol":
|
|
73
|
-
return SymbolLayer;
|
|
74
|
-
case "raster":
|
|
75
|
-
return RasterLayer;
|
|
76
|
-
case "line":
|
|
77
|
-
return LineLayer;
|
|
78
|
-
case "fill":
|
|
79
|
-
return FillLayer;
|
|
80
|
-
case "fill-extrusion":
|
|
81
|
-
return FillExtrusionLayer;
|
|
82
|
-
case "background":
|
|
83
|
-
return BackgroundLayer;
|
|
84
|
-
case "heatmap":
|
|
85
|
-
return HeatmapLayer;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.warn(`Mapbox layer type '${type}' is not supported/`);
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface MapLibreJSONLayer {
|
|
94
|
-
type: string;
|
|
95
|
-
paint: { [k: string]: unknown };
|
|
96
|
-
layout: { [k: string]: unknown };
|
|
97
|
-
source?: string;
|
|
98
|
-
"source-layer"?: string;
|
|
99
|
-
minzoom?: number;
|
|
100
|
-
maxzoom?: number;
|
|
101
|
-
filter?: FilterExpression;
|
|
102
|
-
id: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function asLayerComponent(
|
|
106
|
-
layer: MapLibreJSONLayer,
|
|
107
|
-
): ReactElement<LayerProps> | null {
|
|
108
|
-
const LayerComponent = getLayerComponentType(layer);
|
|
109
|
-
|
|
110
|
-
if (!LayerComponent) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const style = {
|
|
115
|
-
...toCamelCaseKeys(layer.paint),
|
|
116
|
-
...toCamelCaseKeys(layer.layout),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const layerProps: Partial<LayerProps> = {};
|
|
120
|
-
|
|
121
|
-
if (layer.source) {
|
|
122
|
-
layerProps.sourceID = layer.source;
|
|
123
|
-
}
|
|
124
|
-
if (layer["source-layer"]) {
|
|
125
|
-
layerProps.sourceLayerID = layer["source-layer"];
|
|
126
|
-
}
|
|
127
|
-
if (layer.minzoom) {
|
|
128
|
-
layerProps.minZoomLevel = layer.minzoom;
|
|
129
|
-
}
|
|
130
|
-
if (layer.maxzoom) {
|
|
131
|
-
layerProps.maxZoomLevel = layer.maxzoom;
|
|
132
|
-
}
|
|
133
|
-
if (layer.filter) {
|
|
134
|
-
layerProps.filter = layer.filter;
|
|
135
|
-
}
|
|
136
|
-
if (Object.keys(style).length) {
|
|
137
|
-
layerProps.style = style;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return <LayerComponent key={layer.id} id={layer.id} {...layerProps} />;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
interface MapLibreJSONSource {
|
|
144
|
-
type: string;
|
|
145
|
-
url?: string;
|
|
146
|
-
tiles?: string[];
|
|
147
|
-
minzoom?: number;
|
|
148
|
-
maxzoom?: number;
|
|
149
|
-
attribution?: string;
|
|
150
|
-
scheme?: "xyz" | "tms";
|
|
151
|
-
bounds?: number[];
|
|
152
|
-
buffer?: number;
|
|
153
|
-
tileSize?: number;
|
|
154
|
-
coordinates?: [
|
|
155
|
-
[number, number],
|
|
156
|
-
[number, number],
|
|
157
|
-
[number, number],
|
|
158
|
-
[number, number],
|
|
159
|
-
];
|
|
160
|
-
cluster?: boolean;
|
|
161
|
-
clusterMaxZoom?: number;
|
|
162
|
-
clusterMinPoints?: number;
|
|
163
|
-
clusterRadius?: number;
|
|
164
|
-
clusterProperties?: { [propertyName: string]: ExpressionField };
|
|
165
|
-
data?: string | object;
|
|
166
|
-
filter?: FilterExpression;
|
|
167
|
-
generateId?: boolean;
|
|
168
|
-
lineMetrics?: boolean;
|
|
169
|
-
tolerance?: number;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
type SourceProps = {
|
|
173
|
-
url?: string;
|
|
174
|
-
tileUrlTemplates?: string[];
|
|
175
|
-
minZoomLevel?: number;
|
|
176
|
-
maxZoomLevel?: number;
|
|
177
|
-
attribution?: string;
|
|
178
|
-
tms?: boolean;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
function getTileSourceProps(source: MapLibreJSONSource): SourceProps {
|
|
182
|
-
const sourceProps: Partial<SourceProps> = {};
|
|
183
|
-
if (source.url) {
|
|
184
|
-
sourceProps.url = source.url;
|
|
185
|
-
}
|
|
186
|
-
if (source.tiles) {
|
|
187
|
-
sourceProps.tileUrlTemplates = source.tiles;
|
|
188
|
-
}
|
|
189
|
-
if (source.minzoom !== undefined) {
|
|
190
|
-
sourceProps.minZoomLevel = source.minzoom;
|
|
191
|
-
}
|
|
192
|
-
if (source.maxzoom !== undefined) {
|
|
193
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
194
|
-
}
|
|
195
|
-
if (source.attribution) {
|
|
196
|
-
sourceProps.attribution = source.attribution;
|
|
197
|
-
}
|
|
198
|
-
if (source.scheme && source.scheme === "tms") {
|
|
199
|
-
sourceProps.tms = true;
|
|
200
|
-
}
|
|
201
|
-
return sourceProps;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getVectorSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
205
|
-
const sourceProps = { ...getTileSourceProps(source) };
|
|
206
|
-
return <VectorSource key={id} id={id} {...sourceProps} />;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function getRasterSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
210
|
-
const sourceProps: SourceProps & { tileSize?: number } = {
|
|
211
|
-
...getTileSourceProps(source),
|
|
212
|
-
};
|
|
213
|
-
if (source.tileSize) {
|
|
214
|
-
sourceProps.tileSize = source.tileSize;
|
|
215
|
-
}
|
|
216
|
-
return <RasterSource key={id} id={id} {...sourceProps} />;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function getImageSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
220
|
-
const sourceProps = {
|
|
221
|
-
url: source.url,
|
|
222
|
-
coordinates: source.coordinates,
|
|
223
|
-
};
|
|
224
|
-
return <ImageSource key={id} id={id} {...sourceProps} />;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
type ShapeSourceShape = (typeof ShapeSource.prototype.props)["shape"];
|
|
228
|
-
|
|
229
|
-
function getShapeSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
230
|
-
const sourceProps: SourceProps & {
|
|
231
|
-
shape?: ShapeSourceShape;
|
|
232
|
-
cluster?: boolean;
|
|
233
|
-
clusterRadius?: number;
|
|
234
|
-
clusterMaxZoomLevel?: number;
|
|
235
|
-
clusterProperties?: { [propertyName: string]: ExpressionField };
|
|
236
|
-
buffer?: number;
|
|
237
|
-
tolerance?: number;
|
|
238
|
-
lineMetrics?: boolean;
|
|
239
|
-
} = {};
|
|
240
|
-
if (source.data && typeof source.data === "string") {
|
|
241
|
-
sourceProps.url = source.data;
|
|
242
|
-
} else if (source.data && typeof source.data === "object") {
|
|
243
|
-
sourceProps.shape = source.data as ShapeSourceShape;
|
|
244
|
-
}
|
|
245
|
-
if (source.cluster !== undefined) {
|
|
246
|
-
sourceProps.cluster = source.cluster;
|
|
247
|
-
}
|
|
248
|
-
if (source.clusterRadius !== undefined) {
|
|
249
|
-
sourceProps.clusterRadius = source.clusterRadius;
|
|
250
|
-
}
|
|
251
|
-
if (source.maxzoom !== undefined) {
|
|
252
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
253
|
-
}
|
|
254
|
-
if (source.clusterMaxZoom !== undefined) {
|
|
255
|
-
sourceProps.clusterMaxZoomLevel = source.clusterMaxZoom;
|
|
256
|
-
}
|
|
257
|
-
if (source.clusterProperties !== undefined) {
|
|
258
|
-
sourceProps.clusterProperties = source.clusterProperties;
|
|
259
|
-
}
|
|
260
|
-
if (source.buffer !== undefined) {
|
|
261
|
-
sourceProps.buffer = source.buffer;
|
|
262
|
-
}
|
|
263
|
-
if (source.tolerance !== undefined) {
|
|
264
|
-
sourceProps.tolerance = source.tolerance;
|
|
265
|
-
}
|
|
266
|
-
if (source.lineMetrics !== undefined) {
|
|
267
|
-
sourceProps.lineMetrics = source.lineMetrics;
|
|
268
|
-
}
|
|
269
|
-
return <ShapeSource key={id} id={id} {...sourceProps} />;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function asSourceComponent(
|
|
273
|
-
id: string,
|
|
274
|
-
source: MapLibreJSONSource,
|
|
275
|
-
): ReactElement | null {
|
|
276
|
-
switch (source.type) {
|
|
277
|
-
case "vector":
|
|
278
|
-
return getVectorSource(id, source);
|
|
279
|
-
case "raster":
|
|
280
|
-
return getRasterSource(id, source);
|
|
281
|
-
case "image":
|
|
282
|
-
return getImageSource(id, source);
|
|
283
|
-
case "geojson":
|
|
284
|
-
return getShapeSource(id, source);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
console.warn(`MapLibre source type '${source.type}' is not supported`);
|
|
288
|
-
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
interface MapLibreJSON {
|
|
293
|
-
layers?: MapLibreJSONLayer[];
|
|
294
|
-
sources?: { [key: string]: MapLibreJSONSource };
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
interface StyleProps {
|
|
298
|
-
/**
|
|
299
|
-
* A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON.
|
|
300
|
-
*/
|
|
301
|
-
json?: MapLibreJSON | URL;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
306
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
307
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
308
|
-
*
|
|
309
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
310
|
-
*/
|
|
311
|
-
const Style = (props: StyleProps): ReactElement => {
|
|
312
|
-
const [fetchedJson, setFetchedJson] = useState({});
|
|
313
|
-
const json: MapLibreJSON =
|
|
314
|
-
typeof props.json === "object" ? props.json : fetchedJson;
|
|
315
|
-
|
|
316
|
-
// Fetch style when props.json is a URL
|
|
317
|
-
useEffect(() => {
|
|
318
|
-
const abortController = new AbortController();
|
|
319
|
-
const fetchStyleJson = async (url: string): Promise<void> => {
|
|
320
|
-
try {
|
|
321
|
-
const response = await fetch(url, {
|
|
322
|
-
signal: abortController.signal,
|
|
323
|
-
});
|
|
324
|
-
const responseJson = await response.json();
|
|
325
|
-
setFetchedJson(responseJson);
|
|
326
|
-
} catch (error: unknown) {
|
|
327
|
-
const e = error as { name?: string };
|
|
328
|
-
if (e.name === "AbortError") {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
throw e;
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
if (typeof props.json === "string") {
|
|
335
|
-
fetchStyleJson(props.json);
|
|
336
|
-
}
|
|
337
|
-
return function cleanup(): void {
|
|
338
|
-
abortController.abort();
|
|
339
|
-
};
|
|
340
|
-
}, [props.json]);
|
|
341
|
-
|
|
342
|
-
// Extract layer components from json
|
|
343
|
-
const layerComponents = useMemo(() => {
|
|
344
|
-
if (!json.layers) {
|
|
345
|
-
return [];
|
|
346
|
-
}
|
|
347
|
-
return json.layers
|
|
348
|
-
.map(asLayerComponent)
|
|
349
|
-
.filter((x: ReactElement | null) => !!x);
|
|
350
|
-
}, [json.layers]);
|
|
351
|
-
|
|
352
|
-
// Extract source components from json
|
|
353
|
-
const sourceComponents = useMemo(() => {
|
|
354
|
-
const { sources } = json;
|
|
355
|
-
if (!sources || !Object.keys(sources)) {
|
|
356
|
-
return [];
|
|
357
|
-
}
|
|
358
|
-
return Object.entries(sources)
|
|
359
|
-
.map(([id, source]) => asSourceComponent(id, source))
|
|
360
|
-
.filter((x) => !!x);
|
|
361
|
-
}, [json]);
|
|
362
|
-
|
|
363
|
-
return (
|
|
364
|
-
<>
|
|
365
|
-
{sourceComponents}
|
|
366
|
-
{layerComponents}
|
|
367
|
-
</>
|
|
368
|
-
);
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export default Style;
|