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:
gcole
2017-03-28 14:53:56 -07:00
parent c0ebef23fb
commit c9b60e17c2
8 changed files with 450 additions and 9 deletions
@@ -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);
}
}