mirror of
https://github.com/status-im/react-native-mapbox-gl.git
synced 2026-09-01 05:21:14 +00:00
Custom annotation views for Android.
This gives feature parity to Custom Annotation Views between iOS and Android. - Add custom marker view and options for mapbox. - Add an implementation for the Annotation class. - Add a MarkerViewAdapater that transforms Annotations into views that get displayed on the map. - Handle adding and removing of children. - Update custom annotation docs.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.mapbox.reactnativemapboxgl;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewGroupManager;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by gcole on 2/17/17.
|
||||
*/
|
||||
public class RNMGLAnnotationViewManager extends ViewGroupManager<RNMGLAnnotationView> {
|
||||
private LayoutShadowNode _shadowNode;
|
||||
|
||||
private static final String NAME = "RCTMapboxAnnotation";
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RNMGLAnnotationView createViewInstance(ThemedReactContext reactContext) {
|
||||
return new RNMGLAnnotationView(reactContext, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutShadowNode createShadowNodeInstance() {
|
||||
_shadowNode = super.createShadowNodeInstance();
|
||||
return _shadowNode;
|
||||
}
|
||||
|
||||
public LayoutShadowNode getShadowNode() {
|
||||
return _shadowNode;
|
||||
}
|
||||
|
||||
// Props
|
||||
|
||||
@ReactProp(name = "id")
|
||||
public void setAnnotationId(RNMGLAnnotationView view, String value) {
|
||||
view.setAnnotationId(value);
|
||||
}
|
||||
|
||||
@ReactProp(name = "coordinate")
|
||||
public void setCoordinate(RNMGLAnnotationView view, ReadableMap map) {
|
||||
LatLng coordinate = new LatLng();
|
||||
coordinate.setLatitude(map.getDouble("latitude"));
|
||||
coordinate.setLongitude(map.getDouble("longitude"));
|
||||
view.setCoordinate(coordinate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user