|
4 | 4 | */ |
5 | 5 | import { Platform } from 'react-native'; |
6 | 6 |
|
| 7 | +import * as MapboxNative from './map-view.native'; |
| 8 | +import * as MapboxWeb from './map-view.web'; |
| 9 | + |
7 | 10 | // Import the platform-specific implementation |
8 | 11 | // Metro bundler will resolve to the correct file based on platform |
9 | | -const MapboxImpl = Platform.OS === 'web' ? require('./map-view.web').default : require('./map-view.native').default; |
| 12 | +const MapboxImpl = Platform.OS === 'web' ? MapboxWeb.default : MapboxNative.default; |
10 | 13 |
|
11 | 14 | // Re-export all components |
12 | 15 | export const MapView = MapboxImpl.MapView || MapboxImpl; |
13 | | -export const Camera = Platform.OS === 'web' ? require('./map-view.web').Camera : require('./map-view.native').Camera; |
14 | | -export const PointAnnotation = Platform.OS === 'web' ? require('./map-view.web').PointAnnotation : require('./map-view.native').PointAnnotation; |
15 | | -export const UserLocation = Platform.OS === 'web' ? require('./map-view.web').UserLocation : require('./map-view.native').UserLocation; |
16 | | -export const MarkerView = Platform.OS === 'web' ? require('./map-view.web').MarkerView : require('./map-view.native').MarkerView; |
17 | | -export const ShapeSource = Platform.OS === 'web' ? require('./map-view.web').ShapeSource : require('./map-view.native').ShapeSource; |
18 | | -export const SymbolLayer = Platform.OS === 'web' ? require('./map-view.web').SymbolLayer : require('./map-view.native').SymbolLayer; |
19 | | -export const CircleLayer = Platform.OS === 'web' ? require('./map-view.web').CircleLayer : require('./map-view.native').CircleLayer; |
20 | | -export const LineLayer = Platform.OS === 'web' ? require('./map-view.web').LineLayer : require('./map-view.native').LineLayer; |
21 | | -export const FillLayer = Platform.OS === 'web' ? require('./map-view.web').FillLayer : require('./map-view.native').FillLayer; |
22 | | -export const Images = Platform.OS === 'web' ? require('./map-view.web').Images : require('./map-view.native').Images; |
23 | | -export const Callout = Platform.OS === 'web' ? require('./map-view.web').Callout : require('./map-view.native').Callout; |
| 16 | +export const Camera = Platform.OS === 'web' ? MapboxWeb.Camera : MapboxNative.Camera; |
| 17 | +export const PointAnnotation = Platform.OS === 'web' ? MapboxWeb.PointAnnotation : MapboxNative.PointAnnotation; |
| 18 | +export const UserLocation = Platform.OS === 'web' ? MapboxWeb.UserLocation : MapboxNative.UserLocation; |
| 19 | +export const MarkerView = Platform.OS === 'web' ? MapboxWeb.MarkerView : MapboxNative.MarkerView; |
| 20 | +export const ShapeSource = Platform.OS === 'web' ? MapboxWeb.ShapeSource : MapboxNative.ShapeSource; |
| 21 | +export const SymbolLayer = Platform.OS === 'web' ? MapboxWeb.SymbolLayer : MapboxNative.SymbolLayer; |
| 22 | +export const CircleLayer = Platform.OS === 'web' ? MapboxWeb.CircleLayer : MapboxNative.CircleLayer; |
| 23 | +export const LineLayer = Platform.OS === 'web' ? MapboxWeb.LineLayer : MapboxNative.LineLayer; |
| 24 | +export const FillLayer = Platform.OS === 'web' ? MapboxWeb.FillLayer : MapboxNative.FillLayer; |
| 25 | +export const Images = Platform.OS === 'web' ? MapboxWeb.Images : MapboxNative.Images; |
| 26 | +export const Callout = Platform.OS === 'web' ? MapboxWeb.Callout : MapboxNative.Callout; |
24 | 27 |
|
25 | 28 | // Export style URL constants |
26 | | -export const StyleURL = Platform.OS === 'web' ? require('./map-view.web').StyleURL : require('./map-view.native').StyleURL; |
| 29 | +export const StyleURL = Platform.OS === 'web' ? MapboxWeb.StyleURL : MapboxNative.StyleURL; |
27 | 30 |
|
28 | 31 | // Export UserTrackingMode |
29 | | -export const UserTrackingMode = Platform.OS === 'web' ? require('./map-view.web').UserTrackingMode : require('./map-view.native').UserTrackingMode; |
| 32 | +export const UserTrackingMode = Platform.OS === 'web' ? MapboxWeb.UserTrackingMode : MapboxNative.UserTrackingMode; |
30 | 33 |
|
31 | 34 | // Export setAccessToken |
32 | | -export const setAccessToken = Platform.OS === 'web' ? require('./map-view.web').setAccessToken : require('./map-view.native').setAccessToken; |
| 35 | +export const setAccessToken = Platform.OS === 'web' ? MapboxWeb.setAccessToken : MapboxNative.setAccessToken; |
| 36 | + |
| 37 | +// Default export matching Mapbox structure with all properties |
| 38 | +const Mapbox = { |
| 39 | + ...MapboxImpl, |
| 40 | + MapView: MapView, |
| 41 | + Camera: Camera, |
| 42 | + PointAnnotation: PointAnnotation, |
| 43 | + UserLocation: UserLocation, |
| 44 | + MarkerView: MarkerView, |
| 45 | + ShapeSource: ShapeSource, |
| 46 | + SymbolLayer: SymbolLayer, |
| 47 | + CircleLayer: CircleLayer, |
| 48 | + LineLayer: LineLayer, |
| 49 | + FillLayer: FillLayer, |
| 50 | + Images: Images, |
| 51 | + Callout: Callout, |
| 52 | + StyleURL: StyleURL, |
| 53 | + UserTrackingMode: UserTrackingMode, |
| 54 | + setAccessToken: setAccessToken, |
| 55 | +}; |
33 | 56 |
|
34 | | -// Default export matching Mapbox structure |
35 | | -export default MapboxImpl; |
| 57 | +export default Mapbox; |
0 commit comments