Files
react-native-mapbox-gl/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLModule.java
T

97 lines
3.6 KiB
Java
Raw Normal View History

2015-12-12 12:41:50 -08:00
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() {
2015-12-14 09:30:47 -08:00
return "MapboxGLManager";
2015-12-12 12:41:50 -08:00
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setDirectionAnimated(String mapRef, int direction) {
2015-12-12 12:41:50 -08:00
aPackage.getManager().setDirection(aPackage.getManager().getMapView(), direction);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setCenterCoordinateAnimated(String mapRef, double latitude, double longitude) {
2015-12-12 12:41:50 -08:00
WritableMap location = Arguments.createMap();
location.putDouble("latitude", latitude);
location.putDouble("longitude", longitude);
aPackage.getManager().setCenterCoordinate(aPackage.getManager().getMapView(), location);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setCenterCoordinateZoomLevelAnimated(String mapRef, double latitude, double longitude, double zoom) {
2015-12-12 12:41:50 -08:00
WritableMap location = Arguments.createMap();
location.putDouble("latitude", latitude);
location.putDouble("longitude", longitude);
location.putDouble("zoom", zoom);
aPackage.getManager().setCenterCoordinate(aPackage.getManager().getMapView(), location);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void addAnnotations(String mapRef, ReadableArray value) {
2015-12-12 12:41:50 -08:00
aPackage.getManager().setAnnotations(aPackage.getManager().getMapView(), value);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setUserTrackingMode(String mapRef, String mode) {
2015-12-12 12:41:50 -08:00
aPackage.getManager().setMyLocationTrackingMode(aPackage.getManager().getMapView(), mode);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void removeAllAnnotations(String mapRef) {
2015-12-12 12:41:50 -08:00
aPackage.getManager().removeAllAnnotations(aPackage.getManager().getMapView(), true);
}
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setTilt(String mapRef, double pitch) {
2015-12-12 12:41:50 -08:00
aPackage.getManager().setTilt(aPackage.getManager().getMapView(), pitch);
}
2015-12-13 17:37:32 -08:00
@ReactMethod
2015-12-14 10:42:29 -08:00
public void setVisibleCoordinateBoundsAnimated(String mapRef, double latSW, double lngSW,double latNE, double lngNE, float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) {
2015-12-13 17:37:32 -08:00
WritableMap info = Arguments.createMap();
info.putDouble("latSW", latSW);
info.putDouble("lngSW", lngSW);
info.putDouble("latNE", latNE);
info.putDouble("lngNE", lngNE);
info.putDouble("paddingTop", paddingTop);
info.putDouble("paddingRight", paddingRight);
info.putDouble("paddingBottom", paddingBottom);
info.putDouble("paddingLeft", paddingLeft);
aPackage.getManager().setVisibleCoordinateBounds(aPackage.getManager().getMapView(), info);
}
2015-12-12 12:41:50 -08:00
public void setPackage(ReactNativeMapboxGLPackage aPackage) {
this.aPackage = aPackage;
}
}