Skip to content

Commit

Permalink
maplibre v11
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed May 14, 2024
1 parent 71b24f7 commit b6030c3
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 185 deletions.
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group 'com.maplibre.maplibregl'
group 'org.maplibre.maplibregl'
version '1.0-SNAPSHOT'

buildscript {
Expand Down Expand Up @@ -26,7 +26,7 @@ android {

compileSdkVersion 34
ndkVersion "25.1.8937393"
namespace "com.maplibre.maplibregl"
namespace "org.maplibre.maplibregl"

defaultConfig {
minSdkVersion 21
Expand All @@ -41,7 +41,7 @@ android {
targetCompatibility JavaVersion.VERSION_17
}
dependencies {
implementation 'org.maplibre.gl:android-sdk:10.2.0'
implementation 'org.maplibre.gl:android-sdk:11.0.0'
implementation 'org.maplibre.gl:android-plugin-annotation-v9:2.0.0'
implementation 'org.maplibre.gl:android-plugin-offline-v9:2.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'mapbox_gl'
rootProject.name = 'maplibre_gl'
12 changes: 0 additions & 12 deletions android/src/main/java/com/mapbox/mapboxgl/MapBoxUtils.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import org.maplibre.geojson.Polygon;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.camera.CameraUpdateFactory;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.maps.MapLibreMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** Conversions between JSON-like values and MapboxMaps data types. */
/** Conversions between JSON-like values and MapLibreMaps data types. */
class Convert {

private static final String TAG = "Convert";
Expand All @@ -43,7 +43,7 @@ static boolean isScrollByCameraUpdate(Object o) {
return toString(toList(o).get(0)).equals("scrollBy");
}

static CameraUpdate toCameraUpdate(Object o, MapboxMap mapboxMap, float density) {
static CameraUpdate toCameraUpdate(Object o, MapLibreMap maplibreMap, float density) {
final List<?> data = toList(o);
switch (toString(data.get(0))) {
case "newCameraPosition":
Expand All @@ -60,7 +60,7 @@ static CameraUpdate toCameraUpdate(Object o, MapboxMap mapboxMap, float density)
case "newLatLngZoom":
return CameraUpdateFactory.newLatLngZoom(toLatLng(data.get(1)), toFloat(data.get(2)));
case "scrollBy":
mapboxMap.scrollBy(
maplibreMap.scrollBy(
toFractionalPixels(data.get(1), density), toFractionalPixels(data.get(2), density));
return null;
case "zoomBy":
Expand Down Expand Up @@ -164,12 +164,12 @@ private static List<List<LatLng>> toLatLngListList(Object o) {
}

static Polygon interpretListLatLng(List<List<LatLng>> geometry) {
List<List<com.mapbox.geojson.Point>> points = new ArrayList<>(geometry.size());
List<List<org.maplibre.geojson.Point>> points = new ArrayList<>(geometry.size());
for (List<LatLng> innerGeometry : geometry) {
List<com.mapbox.geojson.Point> innerPoints = new ArrayList<>(innerGeometry.size());
List<org.maplibre.geojson.Point> innerPoints = new ArrayList<>(innerGeometry.size());
for (LatLng latLng : innerGeometry) {
innerPoints.add(
com.mapbox.geojson.Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
org.maplibre.geojson.Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
}
points.add(innerPoints);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ static String toString(Object o) {
return (String) o;
}

static void interpretMapboxMapOptions(Object o, MapboxMapOptionsSink sink, Context context) {
static void interpretMapLibreMapOptions(Object o, MapLibreMapOptionsSink sink, Context context) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
final Map<?, ?> data = toMap(o);
final Object cameraTargetBounds = data.get("cameraTargetBounds");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import org.maplibre.android.net.ConnectivityReceiver;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static void copy(InputStream input, OutputStream output) throws IOExcept

@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
MapBoxUtils.getMapbox(context);
MapLibreUtils.getMapLibre(context);

switch (methodCall.method) {
case "installOfflineMapTiles":
Expand All @@ -92,7 +92,7 @@ public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
break;
case "setHttpHeaders":
Map<String, String> headers = (Map<String, String>) methodCall.argument("headers");
MapboxHttpRequestUtil.setHttpHeaders(headers, result);
MapLibreHttpRequestUtil.setHttpHeaders(headers, result);
break;
case "downloadOfflineRegion#setup":
String channelName = methodCall.argument("channelName");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This file is generated by
// ./scripts/lib/generate.dart

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.layers.PropertyValue;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -16,7 +16,7 @@
import com.google.gson.JsonPrimitive;


import static com.mapbox.mapboxgl.Convert.toMap;
import static org.maplibre.maplibregl.Convert.toMap;

class LayerPropertyConverter {
static PropertyValue[] interpretSymbolLayerProperties(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import com.mapbox.mapboxsdk.module.http.HttpRequestUtil;
import org.maplibre.android.module.http.HttpRequestUtil;
import io.flutter.plugin.common.MethodChannel;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;

abstract class MapboxHttpRequestUtil {
abstract class MapLibreHttpRequestUtil {

public static void setHttpHeaders(Map<String, String> headers, MethodChannel.Result result) {
HttpRequestUtil.setOkHttpClient(getOkHttpClient(headers, result).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.view.Gravity;
import androidx.annotation.NonNull;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.maps.MapLibreMapOptions;
import io.flutter.plugin.common.BinaryMessenger;

class MapboxMapBuilder implements MapboxMapOptionsSink {
class MapLibreMapBuilder implements MapLibreMapOptionsSink {
public final String TAG = getClass().getSimpleName();
private final MapboxMapOptions options =
new MapboxMapOptions().attributionEnabled(true).logoEnabled(false).textureMode(true);
private final MapLibreMapOptions options =
new MapLibreMapOptions().attributionEnabled(true).logoEnabled(false).textureMode(true);
private boolean trackCameraPosition = false;
private boolean myLocationEnabled = false;
private boolean dragEnabled = true;
Expand All @@ -24,14 +24,14 @@ class MapboxMapBuilder implements MapboxMapOptionsSink {
private String styleString = "";
private LatLngBounds bounds = null;

MapboxMapController build(
MapLibreMapController build(
int id,
Context context,
BinaryMessenger messenger,
MapboxMapsPlugin.LifecycleProvider lifecycleProvider) {
MapLibreMapsPlugin.LifecycleProvider lifecycleProvider) {

final MapboxMapController controller =
new MapboxMapController(
final MapLibreMapController controller =
new MapLibreMapController(
id, context, messenger, lifecycleProvider, options, styleString, dragEnabled);
controller.init();
controller.setMyLocationEnabled(myLocationEnabled);
Expand Down
Loading

0 comments on commit b6030c3

Please sign in to comment.