mirror of
https://github.com/status-im/react-native-mapbox-gl.git
synced 2026-08-30 20:41:08 +00:00
Add module
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
|
||||
package com.mapbox.reactnativemapboxgl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.views.MapView;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule {
|
||||
|
||||
private static final String TAG = ReactNativeMapboxGLModule.class.getSimpleName();
|
||||
|
||||
private Context context;
|
||||
private ReactNativeMapboxGLPackage aPackage;
|
||||
|
||||
public ReactNativeMapboxGLModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
this.context = reactContext;
|
||||
Log.d(TAG, "Context " + context);
|
||||
Log.d(TAG, "reactContext " + reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Mapbox";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setDirectionAnimated(int direction) {
|
||||
aPackage.getManager().setDirection(aPackage.getManager().getMapView(), direction);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setCenterCoordinateAnimated(double latitude, double longitude) {
|
||||
WritableMap location = Arguments.createMap();
|
||||
location.putDouble("latitude", latitude);
|
||||
location.putDouble("longitude", longitude);
|
||||
aPackage.getManager().setCenterCoordinate(aPackage.getManager().getMapView(), location);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setCenterCoordinateZoomLevelAnimated(double latitude, double longitude, double zoom) {
|
||||
WritableMap location = Arguments.createMap();
|
||||
location.putDouble("latitude", latitude);
|
||||
location.putDouble("longitude", longitude);
|
||||
location.putDouble("zoom", zoom);
|
||||
aPackage.getManager().setCenterCoordinate(aPackage.getManager().getMapView(), location);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void addAnnotation(ReadableArray value) {
|
||||
aPackage.getManager().setAnnotations(aPackage.getManager().getMapView(), value);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setUserTrackingMode(String mode) {
|
||||
aPackage.getManager().setMyLocationTrackingMode(aPackage.getManager().getMapView(), mode);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void removeAllAnnotations() {
|
||||
aPackage.getManager().removeAllAnnotations(aPackage.getManager().getMapView(), true);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setTilt(double pitch) {
|
||||
aPackage.getManager().setTilt(aPackage.getManager().getMapView(), pitch);
|
||||
}
|
||||
|
||||
public void setPackage(ReactNativeMapboxGLPackage aPackage) {
|
||||
this.aPackage = aPackage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user