Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44f4bdc6 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Update Maps API

parent 39a07ffc
Loading
Loading
Loading
Loading
Compare 0890bf45 to 28ff7f36
Original line number Diff line number Diff line
Subproject commit 0890bf454651e90274949af9dca09fbcfbf50d36
Subproject commit 28ff7f36f2b75a29cead8efc25fc0418065db601
+27 −18
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public class BackendMap implements ItemizedLayer.OnItemGestureListener<MarkerIte

    private final Context context;
    private final MapView mapView;
    private final LabelLayer labels;
    private final BuildingLayer buildings;
    private final VectorTileLayer baseLayer;
    private final OSciMap4TileSource tileSource;
@@ -67,10 +68,10 @@ public class BackendMap implements ItemizedLayer.OnItemGestureListener<MarkerIte
        tileSource.setCache(cache);
        baseLayer = mapView.map().setBaseMap(tileSource);
        Layers layers = mapView.map().layers();
        layers.add(buildings = new BuildingLayer(mapView.map(), baseLayer));
        layers.add(new LabelLayer(mapView.map(), baseLayer));
        layers.add(labels = new LabelLayer(mapView.map(), baseLayer));
        layers.add(items = new ItemizedLayer<MarkerItem>(mapView.map(), new MarkerSymbol(new AndroidBitmap(BitmapFactory
                .decodeResource(ResourcesContainer.get(), R.drawable.nop)), 0.5F, 1)));
        layers.add(buildings = new BuildingLayer(mapView.map(), baseLayer));
        items.setOnItemGestureListener(this);
        mapView.map().setTheme(VtmThemes.DEFAULT);
    }
@@ -145,6 +146,7 @@ public class BackendMap implements ItemizedLayer.OnItemGestureListener<MarkerIte
    }

    public synchronized <T extends Markup> T add(T markup) {
        if (markup != null && markup.getType() != null)
            switch (markup.getType()) {
                case MARKER:
                    markupMap.put(markup.getId(), markup);
@@ -153,9 +155,16 @@ public class BackendMap implements ItemizedLayer.OnItemGestureListener<MarkerIte
                    break;
                case LAYER:
                    Layers layers = mapView.map().layers();
                    // TODO: better sorting code
                    layers.add(markup.getLayer(context, mapView.map()));
                    if (hasBuilding()) {
                        layers.remove(buildings);
                        layers.add(buildings);
                    }
                    layers.remove(items);
                    layers.add(items);
                    layers.remove(labels);
                    layers.add(labels);
                    redraw();
                    break;
                default:
+9 −3
Original line number Diff line number Diff line
@@ -19,9 +19,12 @@ package org.microg.gms.maps;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;

import org.oscim.core.BoundingBox;
import org.oscim.core.Box;
import org.oscim.core.GeoPoint;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;

public class GmsMapsTypeHelper {
    public static android.graphics.Point toPoint(org.oscim.core.Point in) {
@@ -36,9 +39,12 @@ public class GmsMapsTypeHelper {
        return new LatLng(geoPoint.getLatitude(), geoPoint.getLongitude());
    }

    public static LatLngBounds toLatLngBounds(BoundingBox box) {
        return new LatLngBounds(new LatLng(box.getMinLatitude(), box.getMinLongitude()),
                new LatLng(box.getMaxLatitude(), box.getMaxLongitude()));
    public static LatLngBounds toLatLngBounds(Box box) {
        double minLon = MercatorProjection.toLongitude(box.xmin);
        double maxLon = MercatorProjection.toLongitude(box.xmax);
        double minLat = MercatorProjection.toLatitude(box.ymax);
        double maxLat = MercatorProjection.toLatitude(box.ymin);
        return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
    }

    public static org.oscim.core.Point fromPoint(android.graphics.Point point) {
+17 −5
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub

    private int markerCounter = 0;
    private int circleCounter = 0;
    private int polylineCounter = 0;
    private int polygonCounter = 0;

    private IOnMarkerClickListener onMarkerClickListener;

    public GoogleMapImpl(LayoutInflater inflater, GoogleMapOptions options) {
@@ -116,6 +119,14 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
        return "c" + circleCounter++;
    }

    private String getNextPolylineId() {
        return "l" + polylineCounter++;
    }

    private String getNextPolygonId() {
        return "p" + polygonCounter++;
    }
    
    /*
    Camera
     */
@@ -182,14 +193,13 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub

    @Override
    public IPolylineDelegate addPolyline(PolylineOptions options) throws RemoteException {
        Log.d(TAG, "not yet usable: addPolyline");
        return new PolylineImpl(options); // TODO
        Log.d(TAG, "addPolyline");
        return backendMap.add(new PolylineImpl(getNextPolylineId(), options, this));
    }

    @Override
    public IPolygonDelegate addPolygon(PolygonOptions options) throws RemoteException {
        Log.d(TAG, "not yet usable: addPolygon");
        return new PolygonImpl(options); // TODO
        return backendMap.add(new PolygonImpl(getNextPolygonId(), options, this));
    }

    @Override
@@ -218,8 +228,10 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
    @Override
    public void clear() throws RemoteException {
        backendMap.clear();
        circleCounter = 0;
        markerCounter = 0;
        circleCounter = 0;
        polylineCounter = 0;
        polygonCounter = 0;
    }

    @Override
+3 −1
Original line number Diff line number Diff line
@@ -17,11 +17,13 @@
package org.microg.gms.maps;

import android.os.RemoteException;

import com.google.android.gms.dynamic.IObjectWrapper;
import com.google.android.gms.dynamic.ObjectWrapper;
import com.google.android.gms.maps.internal.IProjectionDelegate;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.VisibleRegion;

import org.oscim.core.Point;
import org.oscim.map.Viewport;

@@ -49,6 +51,6 @@ public class ProjectionImpl extends IProjectionDelegate.Stub {

    @Override
    public VisibleRegion getVisibleRegion() throws RemoteException {
        return new VisibleRegion(GmsMapsTypeHelper.toLatLngBounds(viewport.getBBox()));
        return new VisibleRegion(GmsMapsTypeHelper.toLatLngBounds(viewport.getBBox(null, 0)));
    }
}
Loading