Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
:thinking: @{issue-author}, closing the issue for lack of activity, if the issue still persist, pls open a new one with steps to reproduce on recent versions
# Close the issue
close: true
"Needs: Project setup instructions":
comment: >
@{issue-author}, sorry for us to look into project setup issues, we require steps to reproduce from `react-native init ...`. If you cannot reproduce starting with a blank project, then compare your setup with a blank working one.
close: true

9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ Please add unreleased changes in the following style:
PR Title ([#123](link to my pr))
```

Implement clustering properties to ShapeSource ([#1745](https://github.com/react-native-mapbox-gl/maps/pull/1745))

### UNRELEASED/10.0.0-beta.0
### UNRELEASED/10.0.0-beta.10

#### Breaking changes:

The setup was changed - see install instructions for more details. In a nuthsell:
* On both android/ios to select mapbox implementation use `RNMapboxMapsImpl`/`$RNMapboxMapsImpl` variable which can be one of (`maplibre`,`mapbox`(aka v10),`mapbox-gl`)
* Default implementation is `maplibre` as it requires not further setup. *WARNING* using mapbox styles from `maplibre` has different pricing than mapbox native sdk-s.
* On Podfile `$RNMBGL.(pre|post)_install` was changed `$RNMapboxMaps.(pre|post)_install`
* Package name was changed from `@react-native-mapbox-gl/maps` to `@rnmapbox/maps`. If you just testing with the v10 version you can use something like [babel-plugin-transform-rename-import](https://www.npmjs.com/package/babel-plugin-transform-rename-import) to keep using the old imports for a while.

* `MapboxGL.setAccessToken` now requires `MapboxGL.setWellKnownTileServer` on maplibre.


#### Changes:

- Implement clustering properties to ShapeSource ([#1745](https://github.com/react-native-mapbox-gl/maps/pull/1745))
- Initial Mapbox V10 support ([#1750](https://github.com/rnmapbox/maps/pull/1750))
- Updated MapLibre on Android to 9.5.2 ([#1780](https://github.com/rnmapbox/maps/pull/1780))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ public void onDidFinishRenderingMap(boolean fully) {
for (Pair<Integer, ReadableArray> preRenderMethod : mPreRenderMethods) {
Integer methodID = preRenderMethod.first;
ReadableArray args = preRenderMethod.second;

mManager.receiveCommand(this, methodID, args);
}
mPreRenderMethods.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public Map<String, Integer> getCommandsMap() {

@Override
public void receiveCommand(RCTMGLMapView mapView, int commandID, @Nullable ReadableArray args) {
String callbackID = args.getString(0);
// allows method calls to work with componentDidMount
MapboxMap mapboxMap = mapView.getMapboxMap();
if (mapboxMap == null) {
Expand All @@ -256,41 +257,42 @@ public void receiveCommand(RCTMGLMapView mapView, int commandID, @Nullable Reada
switch (commandID) {
case METHOD_QUERY_FEATURES_POINT:
mapView.queryRenderedFeaturesAtPoint(
args.getString(0),
callbackID,
ConvertUtils.toPointF(args.getArray(1)),
ExpressionParser.from(args.getArray(2)),
ConvertUtils.toStringList(args.getArray(3)));
break;
case METHOD_QUERY_FEATURES_RECT:
mapView.queryRenderedFeaturesInRect(
args.getString(0),
callbackID,
ConvertUtils.toRectF(args.getArray(1)),
ExpressionParser.from(args.getArray(2)),
ConvertUtils.toStringList(args.getArray(3)));
break;
case METHOD_VISIBLE_BOUNDS:
mapView.getVisibleBounds(args.getString(0));
mapView.getVisibleBounds(callbackID);
break;
case METHOD_GET_POINT_IN_VIEW:
mapView.getPointInView(args.getString(0), GeoJSONUtils.toLatLng(args.getArray(1)));
mapView.getPointInView(callbackID, GeoJSONUtils.toLatLng(args.getArray(1)));
break;
case METHOD_GET_COORDINATE_FROM_VIEW:
mapView.getCoordinateFromView(args.getString(0), ConvertUtils.toPointF(args.getArray(1)));
mapView.getCoordinateFromView(callbackID, ConvertUtils.toPointF(args.getArray(1)));
break;
case METHOD_TAKE_SNAP:
mapView.takeSnap(args.getString(0), args.getBoolean(1));
mapView.takeSnap(callbackID, args.getBoolean(1));
break;
case METHOD_GET_ZOOM:
mapView.getZoom(args.getString(0));
mapView.getZoom(callbackID);
break;
case METHOD_GET_CENTER:
mapView.getCenter(args.getString(0));
mapView.getCenter(callbackID);
break;
case METHOD_SET_HANDLED_MAP_EVENTS:
if(args != null) {
ReadableArray events = args.getArray(1);
ArrayList<String> eventsArray = new ArrayList<>();
for (int i = 1; i < args.size(); i++) {
eventsArray.add(args.getString(i));
for (int i = 0; i < events.size(); i++) {
eventsArray.add(events.getString(i));
}
mapView.setHandledMapChangedEvents(eventsArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,16 @@ public Map<String, Object> getConstants() {
Map<String, String> locationModuleCallbackNames = new HashMap<>();
locationModuleCallbackNames.put("Update", RCTMGLLocationModule.LOCATION_UPDATE);

// tileServer
Map<String, String> tileServers = InstanceManagerImpl.getTileServers();

// implementation
Map<String, String> implementation = new HashMap<>();
implementation.put("Library", InstanceManagerImpl.getLibraryName());

return MapBuilder.<String, Object>builder()
.put("TileServers", tileServers)
.put("Implementation", implementation)
.put("StyleURL", styleURLS)
.put("EventTypes", eventTypes)
.put("UserTrackingModes", userTrackingModes)
Expand Down Expand Up @@ -284,6 +293,11 @@ public Map<String, Object> getConstants() {
.build();
}

@ReactMethod
public void setWellKnownTileServer(final String tileServer) {
InstanceManagerImpl.setWellKnownTileServer(tileServer);
}

@ReactMethod
public void setAccessToken(final String accessToken) {
mReactContext.runOnUiQueueThread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ public static void getInstance(Context context, String accessToken) {
Mapbox.getInstance(context, accessToken);
}

public static void setWellKnownTileServer(String wellKnownTileServer) {
if (wellKnownTileServer != "mapbox") {
Logger.w("InstanceManagerImpl", "setWellKnownTileServer: only mapbox is supported");
return;
}
}

public static String getAccessToken() {
return Mapbox.getAccessToken();
}

public static String getLibraryName() {
return "mapbox-gl";
}

public static Map<String,String> getTileServers() {
HashMap<String, String> result = new HashMap();
result.put("Mapbox", "mapbox");
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
package com.mapbox.rctmgl.impl;

import android.content.Context;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.WellKnownTileServer;
import com.mapbox.mapboxsdk.log.Logger;

import java.util.HashMap;
import java.util.Map;

public class InstanceManagerImpl {
public static void getInstance(Context context, String accessToken) {
Mapbox.getInstance(context, accessToken, WellKnownTileServer.Mapbox);
if (wellKnownTileServer == null) {
Logger.w("InstanceManagerImpl", "setAccessToken requires setWellKnownTileServer for MapLibre, see setWellKnownTileServer docs for implications");
wellKnownTileServer = WellKnownTileServer.MapLibre.name();
}
Mapbox.getInstance(context, accessToken, WellKnownTileServer.valueOf(wellKnownTileServer) );
}

public static Map<String,String> getTileServers() {
HashMap<String, String> result = new HashMap();
result.put("Mapbox", WellKnownTileServer.Mapbox.name());
result.put("MapLibre", WellKnownTileServer.MapLibre.name());
result.put("MapTiler", WellKnownTileServer.MapTiler.name());
return result;
}

static String wellKnownTileServer = null;

public static void setWellKnownTileServer(String wellKnownTileServer) {
InstanceManagerImpl.wellKnownTileServer = wellKnownTileServer;
}

public static String getAccessToken() {
return null;
return Mapbox.getApiKey();
}

public static String getLibraryName() {
return "maplibre";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,7 @@ class RCTMGLImages(context: Context, private val mManager: RCTMGLImagesManager)
if (missingImages.size > 0) {
val task = DownloadMapImageTask(context, map, null)
val params = missingImages.toTypedArray()
for (param in params) {
task.execute(param)
}


task.execute(*params)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ import com.mapbox.geojson.Feature
import com.mapbox.geojson.Point
import com.mapbox.maps.*
import com.mapbox.maps.extension.observable.eventdata.MapLoadingErrorEventData
import com.mapbox.maps.extension.observable.eventdata.StyleImageMissingEventData
import com.mapbox.maps.extension.style.layers.Layer
import com.mapbox.maps.extension.style.layers.generated.*
import com.mapbox.maps.extension.style.layers.getLayer
import com.mapbox.maps.extension.style.utils.unwrap
import com.mapbox.maps.extension.style.layers.properties.generated.Visibility
import com.mapbox.maps.plugin.annotation.annotations
import com.mapbox.maps.plugin.annotation.generated.OnPointAnnotationClickListener
import com.mapbox.maps.plugin.annotation.generated.PointAnnotation
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import com.mapbox.maps.plugin.annotation.generated.createPointAnnotationManager
import com.mapbox.maps.plugin.delegates.listeners.OnCameraChangeListener
import com.mapbox.maps.plugin.delegates.listeners.OnMapIdleListener
import com.mapbox.maps.plugin.delegates.listeners.OnMapLoadErrorListener
import com.mapbox.maps.plugin.delegates.listeners.OnMapLoadedListener
import com.mapbox.maps.plugin.delegates.listeners.*
import com.mapbox.maps.plugin.gestures.*
import com.mapbox.rctmgl.R
import com.mapbox.rctmgl.components.AbstractMapFeature
Expand Down Expand Up @@ -363,7 +360,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
ScreenCoordinate(screenPoint.x + halfWidth,
screenPoint.y + halfHeight)
)
getMapboxMap().queryRenderedFeatures(screenBox,
getMapboxMap().queryRenderedFeatures(RenderedQueryGeometry(screenBox),
RenderedQueryOptions(
source.layerIDs,
null
Expand All @@ -379,7 +376,7 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
hitTouchableSources.add(source)
}
} else {
Logger.e("handleTapInSources", features.error)
Logger.e("handleTapInSources", features.error ?: "n/a")
}
handleTapInSources(sources, screenPoint, hits, hitTouchableSources, handleTap)
}
Expand Down Expand Up @@ -755,5 +752,15 @@ open class RCTMGLMapView(private val mContext: Context, var mManager: RCTMGLMapV
onMapReady(mMap)
val _this = this
mMap.addOnMapLoadedListener(OnMapLoadedListener { (begin, end) -> _this.handleMapChangedEvent(EventTypes.DID_FINISH_LOADING_MAP) })
mMap.addOnStyleImageMissingListener(OnStyleImageMissingListener { (begin, end, id) ->
for (images in mImages) {
if (images.addMissingImageToStyle(id, mMap)) {
return@OnStyleImageMissingListener
}
}
for (images in mImages) {
images.sendImageMissingEvent(id, mMap)
}
})
}
}

This file was deleted.

Loading