Search in sources :

Example 1 with AbstractMapFeature

use of com.mapbox.rctmgl.components.AbstractMapFeature in project maps by rnmapbox.

the class RCTMGLMapView method addFeature.

public void addFeature(View childView, int childPosition) {
    AbstractMapFeature feature = null;
    if (childView instanceof RCTSource) {
        RCTSource source = (RCTSource) childView;
        mSources.put(source.getID(), source);
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLImages) {
        RCTMGLImages images = (RCTMGLImages) childView;
        mImages.add(images);
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLLight) {
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLNativeUserLocation) {
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLPointAnnotation) {
        RCTMGLPointAnnotation annotation = (RCTMGLPointAnnotation) childView;
        mPointAnnotations.put(annotation.getID(), annotation);
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLMarkerView) {
        RCTMGLMarkerView marker = (RCTMGLMarkerView) childView;
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTMGLCamera) {
        mCamera = (RCTMGLCamera) childView;
        feature = (AbstractMapFeature) childView;
    } else if (childView instanceof RCTLayer) {
        feature = (RCTLayer) childView;
    } else if (childView instanceof ViewGroup) {
        ViewGroup children = (ViewGroup) childView;
        for (int i = 0; i < children.getChildCount(); i++) {
            addFeature(children.getChildAt(i), childPosition);
        }
    }
    if (feature != null) {
        if (mQueuedFeatures == null) {
            feature.addToMap(this);
            mFeatures.add(childPosition, feature);
        } else {
            mQueuedFeatures.add(childPosition, feature);
        }
    }
}
Also used : RCTMGLMarkerView(com.mapbox.rctmgl.components.annotation.RCTMGLMarkerView) RCTMGLLight(com.mapbox.rctmgl.components.styles.light.RCTMGLLight) RCTSource(com.mapbox.rctmgl.components.styles.sources.RCTSource) ViewGroup(android.view.ViewGroup) RCTMGLNativeUserLocation(com.mapbox.rctmgl.components.location.RCTMGLNativeUserLocation) AbstractMapFeature(com.mapbox.rctmgl.components.AbstractMapFeature) RCTMGLImages(com.mapbox.rctmgl.components.images.RCTMGLImages) RCTLayer(com.mapbox.rctmgl.components.styles.layers.RCTLayer) RCTMGLPointAnnotation(com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation) RCTMGLCamera(com.mapbox.rctmgl.components.camera.RCTMGLCamera)

Example 2 with AbstractMapFeature

use of com.mapbox.rctmgl.components.AbstractMapFeature in project maps by rnmapbox.

the class RCTMGLMapView method removeFeature.

public void removeFeature(int childPosition) {
    AbstractMapFeature feature = features().get(childPosition);
    if (feature == null) {
        return;
    }
    if (feature instanceof RCTSource) {
        RCTSource source = (RCTSource) feature;
        mSources.remove(source.getID());
    } else if (feature instanceof RCTMGLPointAnnotation) {
        RCTMGLPointAnnotation annotation = (RCTMGLPointAnnotation) feature;
        if (annotation.getMapboxID() == mActiveMarkerID) {
            mActiveMarkerID = -1;
        }
        mPointAnnotations.remove(annotation.getID());
    } else if (feature instanceof RCTMGLImages) {
        RCTMGLImages images = (RCTMGLImages) feature;
        mImages.remove(images);
    }
    feature.removeFromMap(this);
    features().remove(feature);
}
Also used : RCTSource(com.mapbox.rctmgl.components.styles.sources.RCTSource) AbstractMapFeature(com.mapbox.rctmgl.components.AbstractMapFeature) RCTMGLImages(com.mapbox.rctmgl.components.images.RCTMGLImages) RCTMGLPointAnnotation(com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation)

Example 3 with AbstractMapFeature

use of com.mapbox.rctmgl.components.AbstractMapFeature in project maps by rnmapbox.

the class RCTMGLMapView method addQueuedFeatures.

public void addQueuedFeatures() {
    if (mQueuedFeatures != null && mQueuedFeatures.size() > 0) {
        for (int i = 0; i < mQueuedFeatures.size(); i++) {
            AbstractMapFeature feature = mQueuedFeatures.get(i);
            feature.addToMap(this);
            mFeatures.add(feature);
        }
        mQueuedFeatures = null;
    }
}
Also used : AbstractMapFeature(com.mapbox.rctmgl.components.AbstractMapFeature)

Aggregations

AbstractMapFeature (com.mapbox.rctmgl.components.AbstractMapFeature)3 RCTMGLPointAnnotation (com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation)2 RCTMGLImages (com.mapbox.rctmgl.components.images.RCTMGLImages)2 RCTSource (com.mapbox.rctmgl.components.styles.sources.RCTSource)2 ViewGroup (android.view.ViewGroup)1 RCTMGLMarkerView (com.mapbox.rctmgl.components.annotation.RCTMGLMarkerView)1 RCTMGLCamera (com.mapbox.rctmgl.components.camera.RCTMGLCamera)1 RCTMGLNativeUserLocation (com.mapbox.rctmgl.components.location.RCTMGLNativeUserLocation)1 RCTLayer (com.mapbox.rctmgl.components.styles.layers.RCTLayer)1 RCTMGLLight (com.mapbox.rctmgl.components.styles.light.RCTMGLLight)1