use of com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation in project maps by rnmapbox.
the class RCTMGLMapView method onMarkerClick.
public void onMarkerClick(@NonNull PointAnnotation symbol) {
mAnnotationClicked = true;
final long selectedMarkerID = symbol.getId();
RCTMGLPointAnnotation activeAnnotation = null;
RCTMGLPointAnnotation nextActiveAnnotation = null;
for (String key : mPointAnnotations.keySet()) {
RCTMGLPointAnnotation annotation = mPointAnnotations.get(key);
final long curMarkerID = annotation.getMapboxID();
if (mActiveMarkerID == curMarkerID) {
activeAnnotation = annotation;
}
if (selectedMarkerID == curMarkerID && mActiveMarkerID != curMarkerID) {
nextActiveAnnotation = annotation;
}
}
if (activeAnnotation != null) {
deselectAnnotation(activeAnnotation);
}
if (nextActiveAnnotation != null) {
selectAnnotation(nextActiveAnnotation);
}
}
use of com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation 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);
}
}
}
use of com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation 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);
}
use of com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation in project maps by rnmapbox.
the class RCTMGLMapView method createSymbolManager.
public void createSymbolManager(Style style) {
symbolManager = new SymbolManager(this, mMap, style);
symbolManager.setIconAllowOverlap(true);
symbolManager.addClickListener(SymbolClickListenerImpl.annotationClickListener(new SymbolClickListenerImpl.Listener() {
@Override
public boolean onAnnotationClick(Symbol symbol) {
onMarkerClick(symbol);
return true;
}
}));
symbolManager.addDragListener(new OnSymbolDragListener() {
@Override
public void onAnnotationDragStarted(Symbol symbol) {
mAnnotationClicked = true;
final long selectedMarkerID = symbol.getId();
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
if (annotation != null) {
annotation.onDragStart();
}
}
@Override
public void onAnnotationDrag(Symbol symbol) {
final long selectedMarkerID = symbol.getId();
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
if (annotation != null) {
annotation.onDrag();
}
}
@Override
public void onAnnotationDragFinished(Symbol symbol) {
mAnnotationClicked = false;
final long selectedMarkerID = symbol.getId();
RCTMGLPointAnnotation annotation = getPointAnnotationByMarkerID(selectedMarkerID);
if (annotation != null) {
annotation.onDragEnd();
}
}
});
mMap.addOnMapClickListener(this);
mMap.addOnMapLongClickListener(this);
}
use of com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotation in project maps by rnmapbox.
the class RCTMGLMapView method onMarkerClick.
public void onMarkerClick(@NonNull Symbol symbol) {
mAnnotationClicked = true;
final long selectedMarkerID = symbol.getId();
RCTMGLPointAnnotation activeAnnotation = null;
RCTMGLPointAnnotation nextActiveAnnotation = null;
for (String key : mPointAnnotations.keySet()) {
RCTMGLPointAnnotation annotation = mPointAnnotations.get(key);
final long curMarkerID = annotation.getMapboxID();
if (mActiveMarkerID == curMarkerID) {
activeAnnotation = annotation;
}
if (selectedMarkerID == curMarkerID && mActiveMarkerID != curMarkerID) {
nextActiveAnnotation = annotation;
}
}
if (activeAnnotation != null) {
deselectAnnotation(activeAnnotation);
}
if (nextActiveAnnotation != null) {
selectAnnotation(nextActiveAnnotation);
}
}
Aggregations