Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
val locationModuleCallbackNames: MutableMap<String, String> = HashMap()
locationModuleCallbackNames["Update"] = RNMBXLocationModule.LOCATION_UPDATE
return MapBuilder.builder<String, Any>()
// Deprecated: means v10 or later, always true. Will be removed in next major version.
.put("MapboxV10", true)
.put("StyleURL", styleURLS)
.put("EventTypes", eventTypes)
Expand Down
2 changes: 1 addition & 1 deletion docs/MapView.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ boolean
```
[Android only] Enable/Disable use of GLSurfaceView instead of TextureView.

_defaults to:_ `RNMBXModule.MapboxV10 ? true : false`
_defaults to:_ `true`


### requestDisallowInterceptTouchEvent
Expand Down
2 changes: 0 additions & 2 deletions docs/MarkerView.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ the view, and (1, 1) is the bottom-right corner. Defaults to the center at (0.5,
```tsx
boolean
```
@v10
Whether or not nearby markers on the map should all be displayed. If false, adjacent
markers will 'collapse' and only one will be shown. Defaults to false.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5320,7 +5320,7 @@
"name": "surfaceView",
"required": false,
"type": "boolean",
"default": "RNMBXModule.MapboxV10 ? true : false",
"default": "true",
"description": "[Android only] Enable/Disable use of GLSurfaceView instead of TextureView."
},
{
Expand Down Expand Up @@ -5697,7 +5697,7 @@
"required": false,
"type": "boolean",
"default": "false",
"description": "@v10\n\nWhether or not nearby markers on the map should all be displayed. If false, adjacent\nmarkers will 'collapse' and only one will be shown. Defaults to false."
"description": "Whether or not nearby markers on the map should all be displayed. If false, adjacent\nmarkers will 'collapse' and only one will be shown. Defaults to false."
},
{
"name": "allowOverlapWithPuck",
Expand Down
1 change: 1 addition & 0 deletions ios/RNMBX/RNMBXModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RNMBXModule : NSObject {
@objc
func constantsToExport() -> [AnyHashable: Any]! {
return [
// Deprecated: means v10 or later, always true. Will be removed in next major version.
"MapboxV10":true,
"StyleURL":
[
Expand Down
2 changes: 1 addition & 1 deletion setup-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ NativeModules.RNMBXModule = {
setTelemetryEnabled: jest.fn(),
setConnected: jest.fn(),
clearData: jest.fn(),

// Deprecated: means v10 or later, always true. Will be removed in next major version.
MapboxV10: true,
};

Expand Down
182 changes: 70 additions & 112 deletions src/components/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ if (RNMBXModule == null) {
'Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.',
);
}
if (!RNMBXModule.MapboxV10) {
console.warn(
'@rnmapbox/maps: Non v10 implementations are deprecated and will be removed in next version - see https://github.com/rnmapbox/maps/wiki/Deprecated-RNMapboxImpl-Maplibre',
);
}

const styles = StyleSheet.create({
matchParent: { flex: 1 },
Expand Down Expand Up @@ -494,7 +489,7 @@ class MapView extends NativeBridgeComponent(
compassFadeWhenNorth: false,
logoEnabled: true,
scaleBarEnabled: true,
surfaceView: RNMBXModule.MapboxV10 ? true : false,
surfaceView: true,
requestDisallowInterceptTouchEvent: false,
regionWillChangeDebounceTime: 10,
regionDidChangeDebounceTime: 500,
Expand Down Expand Up @@ -591,83 +586,81 @@ class MapView extends NativeBridgeComponent(
}

_setHandledMapChangedEvents(props: Props) {
if (isAndroid() || RNMBXModule.MapboxV10) {
const events: string[] = [];

function addIfHasHandler(name: CallbablePropKeysWithoutOn) {
if (props[`on${name}`] != null) {
if (EventTypes[name] == null) {
if (name === 'DidFailLoadingMap') {
console.warn(
`rnmapbox maps: on${name} is deprecated, please use onMapLoadingError`,
);
} else {
console.warn(`rnmapbox maps: ${name} is not supported`);
}
const events: string[] = [];

function addIfHasHandler(name: CallbablePropKeysWithoutOn) {
if (props[`on${name}`] != null) {
if (EventTypes[name] == null) {
if (name === 'DidFailLoadingMap') {
console.warn(
`rnmapbox maps: on${name} is deprecated, please use onMapLoadingError`,
);
} else {
events.push(EventTypes[name]);
return true;
console.warn(`rnmapbox maps: ${name} is not supported`);
}
} else {
events.push(EventTypes[name]);
return true;
}
return false;
}
return false;
}

addIfHasHandler('RegionWillChange');
addIfHasHandler('RegionIsChanging');
addIfHasHandler('RegionDidChange');
addIfHasHandler('UserLocationUpdate');
addIfHasHandler('WillStartLoadingMap');
addIfHasHandler('DidFinishLoadingMap');
addIfHasHandler('MapLoadingError');
addIfHasHandler('DidFailLoadingMap');
addIfHasHandler('WillStartRenderingFrame');
addIfHasHandler('DidFinishRenderingFrame');
addIfHasHandler('DidFinishRenderingFrameFully');
addIfHasHandler('WillStartRenderingMap');
addIfHasHandler('DidFinishRenderingMap');
addIfHasHandler('DidFinishRenderingMapFully');
addIfHasHandler('DidFinishLoadingStyle');

addIfHasHandler('CameraChanged');
addIfHasHandler('MapIdle');

if (addIfHasHandler('RegionDidChange')) {
if (!this.deprecationLogged.regionDidChange) {
console.warn(
'onRegionDidChange is deprecated and will be removed in next release - please use onMapIdle. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
);
this.deprecationLogged.regionDidChange = true;
}
if (props.onMapIdle) {
console.warn(
'rnmapbox/maps: only one of MapView.onRegionDidChange or onMapIdle is supported',
);
}
addIfHasHandler('RegionWillChange');
addIfHasHandler('RegionIsChanging');
addIfHasHandler('RegionDidChange');
addIfHasHandler('UserLocationUpdate');
addIfHasHandler('WillStartLoadingMap');
addIfHasHandler('DidFinishLoadingMap');
addIfHasHandler('MapLoadingError');
addIfHasHandler('DidFailLoadingMap');
addIfHasHandler('WillStartRenderingFrame');
addIfHasHandler('DidFinishRenderingFrame');
addIfHasHandler('DidFinishRenderingFrameFully');
addIfHasHandler('WillStartRenderingMap');
addIfHasHandler('DidFinishRenderingMap');
addIfHasHandler('DidFinishRenderingMapFully');
addIfHasHandler('DidFinishLoadingStyle');

addIfHasHandler('CameraChanged');
addIfHasHandler('MapIdle');

if (addIfHasHandler('RegionDidChange')) {
if (!this.deprecationLogged.regionDidChange) {
console.warn(
'onRegionDidChange is deprecated and will be removed in next release - please use onMapIdle. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
);
this.deprecationLogged.regionDidChange = true;
}
if (addIfHasHandler('RegionIsChanging')) {
if (!this.deprecationLogged.regionIsChanging) {
console.warn(
'onRegionIsChanging is deprecated and will be removed in next release - please use onCameraChanged. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
);
this.deprecationLogged.regionIsChanging = true;
}
if (props.onCameraChanged) {
console.warn(
'rnmapbox/maps: only one of MapView.onRegionIsChanging or onCameraChanged is supported',
);
}
if (props.onMapIdle) {
console.warn(
'rnmapbox/maps: only one of MapView.onRegionDidChange or onMapIdle is supported',
);
}

if (props.onRegionWillChange) {
}
if (addIfHasHandler('RegionIsChanging')) {
if (!this.deprecationLogged.regionIsChanging) {
console.warn(
'onRegionIsChanging is deprecated and will be removed in next release - please use onCameraChanged. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
);
this.deprecationLogged.regionIsChanging = true;
}
if (props.onCameraChanged) {
console.warn(
'onRegionWillChange is deprecated and will be removed in v10 - please use onRegionIsChanging',
'rnmapbox/maps: only one of MapView.onRegionIsChanging or onCameraChanged is supported',
);
}
}

this._runNativeMethod('setHandledMapChangedEvents', this._nativeRef, [
events,
]);
if (props.onRegionWillChange) {
console.warn(
'onRegionWillChange is deprecated and will be removed in v10 - please use onRegionIsChanging',
);
}

this._runNativeMethod('setHandledMapChangedEvents', this._nativeRef, [
events,
]);
}

/**
Expand Down Expand Up @@ -770,10 +763,7 @@ class MapView extends NativeBridgeComponent(
filter: FilterExpression | [] = [],
layerIDs: string[] | null = null,
): Promise<GeoJSON.FeatureCollection | undefined> {
if (
bbox != null &&
(bbox.length === 4 || (RNMBXModule.MapboxV10 && bbox.length === 0))
) {
if (bbox != null && (bbox.length === 4 || bbox.length === 0)) {
const res = await this._runNative<{ data: GeoJSON.FeatureCollection }>(
'queryRenderedFeaturesInRect',
[bbox, getFilter(filter), layerIDs],
Expand Down Expand Up @@ -891,12 +881,6 @@ class MapView extends NativeBridgeComponent(
* v10 only
*/
async clearData(): Promise<void> {
if (!RNMBXModule.MapboxV10) {
console.warn(
'RNMapbox: clearData is only implemented in v10 implementation or later',
);
return;
}
await this._runNative<void>('clearData');
}

Expand Down Expand Up @@ -956,13 +940,6 @@ class MapView extends NativeBridgeComponent(
sourceId: string,
sourceLayerId: string | null = null,
): Promise<void> {
if (!RNMBXModule.MapboxV10) {
console.warn(
'RNMapbox: setFeatureState is only implemented in v10 implementation or later',
);
return;
}

await this._runNative<void>('setFeatureState', [
featureId,
state,
Expand All @@ -983,13 +960,6 @@ class MapView extends NativeBridgeComponent(
sourceId: string,
sourceLayerId: string | null = null,
): Promise<Readonly<Record<string, unknown>>> {
if (!RNMBXModule.MapboxV10) {
console.warn(
'RNMapbox: setFeatureState is only implemented in v10 implementation or later',
);
return {};
}

const res = await this._runNative<{
featureState: Readonly<Record<string, unknown>>;
}>('getFeatureState', [featureId, sourceId, sourceLayerId]);
Expand All @@ -1013,13 +983,6 @@ class MapView extends NativeBridgeComponent(
sourceId: string,
sourceLayerId: string | null = null,
): Promise<void> {
if (!RNMBXModule.MapboxV10) {
console.warn(
'RNMapbox: removeFeatureState is only implemented in v10 implementation or later',
);
return;
}

await this._runNative<void>('removeFeatureState', [
featureId,
stateKey,
Expand Down Expand Up @@ -1187,13 +1150,11 @@ class MapView extends NativeBridgeComponent(
return;
}

if (RNMBXModule.MapboxV10) {
if (!this.deprecationLogged.contentInset) {
console.warn(
'@rnmapbox/maps: contentInset is deprecated, use Camera padding instead.',
);
this.deprecationLogged.contentInset = true;
}
if (!this.deprecationLogged.contentInset) {
console.warn(
'@rnmapbox/maps: contentInset is deprecated, use Camera padding instead.',
);
this.deprecationLogged.contentInset = true;
}

if (!Array.isArray(this.props.contentInset)) {
Expand Down Expand Up @@ -1235,9 +1196,6 @@ class MapView extends NativeBridgeComponent(
}

_setLocalizeLabels(props: Props) {
if (!RNMBXModule.MapboxV10) {
return;
}
if (typeof props.localizeLabels === 'boolean') {
props.localizeLabels = {
locale: 'current',
Expand Down
25 changes: 1 addition & 24 deletions src/components/MarkerView.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React from 'react';
import { NativeModules, Platform, type ViewProps } from 'react-native';
import { type ViewProps } from 'react-native';

import RNMBXMakerViewContentComponent from '../specs/RNMBXMarkerViewContentNativeComponent';
import NativeMarkerViewComponent from '../specs/RNMBXMarkerViewNativeComponent';
import { type Position } from '../types/Position';
import { toJSONString } from '../utils';
import { makePoint } from '../utils/geoUtils';

import PointAnnotation from './PointAnnotation';

const Mapbox = NativeModules.RNMBXModule;

type Props = ViewProps & {
/**
* The center point (specified as a map coordinate) of the marker.
Expand All @@ -27,8 +23,6 @@ type Props = ViewProps & {
};

/**
* @v10
*
* Whether or not nearby markers on the map should all be displayed. If false, adjacent
* markers will 'collapse' and only one will be shown. Defaults to false.
*/
Expand Down Expand Up @@ -69,17 +63,6 @@ class MarkerView extends React.PureComponent<Props> {
isSelected: false,
};

static lastId = 0;
__idForPointAnnotation?: string;

_idForPointAnnotation(): string {
if (this.__idForPointAnnotation === undefined) {
MarkerView.lastId = MarkerView.lastId + 1;
this.__idForPointAnnotation = `MV-${MarkerView.lastId}`;
}
return this.__idForPointAnnotation;
}

_getCoordinate(coordinate: Position): string | undefined {
if (!coordinate) {
return undefined;
Expand All @@ -99,12 +82,6 @@ class MarkerView extends React.PureComponent<Props> {
);
}

if (Platform.OS === 'ios' && !Mapbox.MapboxV10) {
return (
<PointAnnotation id={this._idForPointAnnotation()} {...this.props} />
);
}

const { anchor = { x: 0.5, y: 0.5 } } = this.props;

return (
Expand Down
Loading
Loading