com.mapbox.mapboxsdk.style.expressions.Expression Java Examples

The following examples show how to use com.mapbox.mapboxsdk.style.expressions.Expression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: graphhopper-navigation-android   Author: graphhopper   File: NavigationMapRoute.java    License: MIT License 6 votes vote down vote up
/**
 * When the user switches an alternative route to a primary route, this method alters the
 * appearance.
 */
private void updatePrimaryRoute(String layerId, int index) {
  Layer layer = mapboxMap.getLayer(layerId);
  if (layer != null) {
    layer.setProperties(
      PropertyFactory.lineColor(match(
        Expression.toString(get(CONGESTION_KEY)),
        color(index == primaryRouteIndex ? routeDefaultColor : alternativeRouteDefaultColor),
        stop("moderate", color(index == primaryRouteIndex ? routeModerateColor : alternativeRouteModerateColor)),
        stop("heavy", color(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)),
        stop("severe", color(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor))
        )
      )
    );
    if (index == primaryRouteIndex) {
      mapboxMap.removeLayer(layer);
      mapboxMap.addLayerBelow(layer, WAYPOINT_LAYER_ID);
    }
  }
}
 
Example #2
Source Project: mapbox-plugins-android   Author: mapbox   File: LocalizationPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void convertExpression(@NonNull MapLocale mapLocale, Layer layer,
                               PropertyValue<?> textFieldProperty, boolean isStreetsV7) {
  Expression textFieldExpression = textFieldProperty.getExpression();
  if (textFieldExpression != null) {
    MapLocale newMapLocale = mapLocale;
    String mapLanguage = mapLocale.getMapLanguage();
    if (mapLanguage.startsWith("name_zh")) {
      // need to re-get mapLocale, since the default is for street-v8
      newMapLocale = getChineseMapLocale(mapLocale, isStreetsV7);
      Timber.d("reset mapLocale to: %s", newMapLocale.getMapLanguage());
    }

    String text = textFieldExpression.toString().replaceAll(EXPRESSION_REGEX, newMapLocale.getMapLanguage());
    if (text.startsWith("[\"step") && textFieldExpression.toArray().length % 2 == 0) {
      // got an invalid step expression from core, we need to add an additional name_x into step
      text = text.replaceAll(STEP_REGEX, STEP_TEMPLATE);
    }
    layer.setProperties(textField(raw(text)));
  }
}
 
Example #3
Source Project: mapbox-plugins-android   Author: mapbox   File: LocalizationPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void convertExpressionV8(@NonNull MapLocale mapLocale, Layer layer, PropertyValue<?> textFieldProperty) {
  Expression textFieldExpression = textFieldProperty.getExpression();
  if (textFieldExpression != null) {
    String stringExpression =
      textFieldExpression.toString().replaceAll(EXPRESSION_V8_REGEX_LOCALIZED, EXPRESSION_V8_TEMPLATE_BASE);

    String mapLanguage = mapLocale.getMapLanguage();
    if (!mapLanguage.equals(MapLocale.ENGLISH)) {
      if (mapLanguage.equals("name_zh")) {
        mapLanguage = MapLocale.SIMPLIFIED_CHINESE;
      }
      stringExpression = stringExpression.replaceAll(EXPRESSION_V8_REGEX_BASE,
        String.format(Locale.US,
          EXPRESSION_V8_TEMPLATE_LOCALIZED,
          mapLanguage,
          mapLanguage));
    }
    layer.setProperties(textField(raw(stringExpression)));
  }
}
 
Example #4
Source Project: mapbox-plugins-android   Author: mapbox   File: TrafficPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
static LineLayer getLineLayer(String lineLayerId, float minZoom, Expression filter,
                              Expression lineColorExpression, Expression lineWidthExpression,
                              Expression lineOffsetExpression, Expression lineOpacityExpression) {
  LineLayer lineLayer = new LineLayer(lineLayerId, TrafficData.SOURCE_ID);
  lineLayer.setSourceLayer(TrafficData.SOURCE_LAYER);
  lineLayer.setProperties(
    lineCap(Property.LINE_CAP_ROUND),
    lineJoin(Property.LINE_JOIN_ROUND),
    lineColor(lineColorExpression),
    lineWidth(lineWidthExpression),
    lineOffset(lineOffsetExpression)
  );
  if (lineOpacityExpression != null) {
    lineLayer.setProperties(lineOpacity(lineOpacityExpression));
  }

  lineLayer.setFilter(filter);
  lineLayer.setMinZoom(minZoom);
  return lineLayer;
}
 
Example #5
Source Project: AirMapSDK-Android   Author: airmap   File: MapStyleController.java    License: Apache License 2.0 6 votes vote down vote up
public void highlight(@NonNull Feature feature, AirMapAdvisory advisory) {
    // remove old highlight
    unhighlight();

    // add new highlight
    String sourceId = feature.getStringProperty("ruleset_id");
    highlightLayerId = "airmap|highlight|line|" + sourceId;
    LineLayer highlightLayer = map.getMap().getStyle().getLayerAs(highlightLayerId);
    highlightLayer.setSourceLayer(sourceId + "_" + advisory.getType().toString());

    // feature's airspace_id can be an int or string (tile server bug), so match on either
    Expression filter;
    try {
        int airspaceId = Integer.parseInt(advisory.getId());
        filter = Expression.any(Expression.eq(Expression.get("id"), advisory.getId()), Expression.eq(Expression.get("id"), airspaceId));
    } catch (NumberFormatException e) {
        filter = Expression.any(Expression.eq(Expression.get("id"), advisory.getId()));
    }
    highlightLayer.setFilter(filter);
}
 
Example #6
Source Project: AirMapSDK-Android   Author: airmap   File: MapStyleController.java    License: Apache License 2.0 6 votes vote down vote up
public void highlight(Feature feature) {
    String id = feature.getStringProperty("id");
    String type = feature.getStringProperty("category");

    // remove old highlight
    unhighlight();

    // add new highlight
    String sourceId = feature.getStringProperty("ruleset_id");
    highlightLayerId = "airmap|highlight|line|" + sourceId;
    LineLayer highlightLayer = map.getMap().getStyle().getLayerAs(highlightLayerId);
    highlightLayer.setSourceLayer(sourceId + "_" + type);

    // feature's airspace_id can be an int or string (tile server bug), so match on either
    Expression filter;
    try {
        int airspaceId = Integer.parseInt(id);
        filter = Expression.any(Expression.eq(Expression.get("id"), id), Expression.eq(Expression.get("id"), airspaceId));
    } catch (NumberFormatException e) {
        filter = Expression.any(Expression.eq(Expression.get("id"), id));
    }
    highlightLayer.setFilter(filter);
}
 
Example #7
Source Project: deltachat-android   Author: deltachat   File: MapDataManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void initLastPositionLayer() {
    GeoJsonSource lastPositionSource = new GeoJsonSource(LAST_POSITION_SOURCE);
    mapboxStyle.addSource(lastPositionSource);
    Expression markerSize =
            switchCase(toBool(get(MARKER_SELECTED)), literal(1.75f), literal(1.25f));
    mapboxStyle.addLayerBelow(new SymbolLayer(LAST_POSITION_LAYER, LAST_POSITION_SOURCE).withProperties(
            iconImage(get(LAST_POSITION_ICON)),
                 /* all info window and marker image to appear at the same time*/
            iconAllowOverlap(true),
            iconIgnorePlacement(true),
            iconSize(markerSize),
            textField(get(LAST_POSITION_LABEL)),
            textAnchor(TEXT_ANCHOR_TOP),
            textOffset(new Float[]{0.0f, 1.0f}),
            textAllowOverlap(true),
            textIgnorePlacement(true)
    ).withFilter(filterProvider.getTimeFilter()), INFO_WINDOW_LAYER);
}
 
Example #8
Source Project: graphhopper-navigation-android   Author: graphhopper   File: NavigationMapRoute.java    License: MIT License 5 votes vote down vote up
/**
 * Add the route layer to the map either using the custom style values or the default.
 */
private void addRouteLayer(String layerId, String sourceId, int index) {
  float scale = index == primaryRouteIndex ? routeScale : alternativeRouteScale;
  Layer routeLayer = new LineLayer(layerId, sourceId).withProperties(
    PropertyFactory.lineCap(Property.LINE_CAP_ROUND),
    PropertyFactory.lineJoin(Property.LINE_JOIN_ROUND),
    PropertyFactory.lineWidth(interpolate(
      exponential(1.5f), zoom(),
      stop(4f, 3f * scale),
      stop(10f, 4f * scale),
      stop(13f, 6f * scale),
      stop(16f, 10f * scale),
      stop(19f, 14f * scale),
      stop(22f, 18f * scale)
      )
    ),
    PropertyFactory.lineColor(match(
      Expression.toString(get(CONGESTION_KEY)),
      color(index == primaryRouteIndex ? routeDefaultColor : alternativeRouteDefaultColor),
      stop("moderate", color(index == primaryRouteIndex ? routeModerateColor : alternativeRouteModerateColor)),
      stop("heavy", color(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor)),
      stop("severe", color(index == primaryRouteIndex ? routeSevereColor : alternativeRouteSevereColor))
      )
    )
  );
  MapUtils.addLayerToMap(mapboxMap, routeLayer, belowLayer);
}
 
Example #9
Source Project: graphhopper-navigation-android   Author: graphhopper   File: NavigationMapRoute.java    License: MIT License 5 votes vote down vote up
private void drawWaypointMarkers(@NonNull MapboxMap mapboxMap, @Nullable Drawable originMarker,
                                 @Nullable Drawable destinationMarker) {
  if (originMarker == null || destinationMarker == null) {
    return;
  }

  SymbolLayer waypointLayer = mapboxMap.getLayerAs(WAYPOINT_LAYER_ID);
  if (waypointLayer == null) {
    Bitmap bitmap = MapImageUtils.getBitmapFromDrawable(originMarker);
    mapboxMap.addImage("originMarker", bitmap);
    bitmap = MapImageUtils.getBitmapFromDrawable(destinationMarker);
    mapboxMap.addImage("destinationMarker", bitmap);

    waypointLayer = new SymbolLayer(WAYPOINT_LAYER_ID, WAYPOINT_SOURCE_ID).withProperties(
      PropertyFactory.iconImage(match(
        Expression.toString(get("waypoint")), literal("originMarker"),
        stop("origin", literal("originMarker")),
        stop("destination", literal("destinationMarker"))
        )
      ),
      PropertyFactory.iconSize(interpolate(
        exponential(1.5f), zoom(),
        stop(22f, 2.8f),
        stop(12f, 1.3f),
        stop(10f, 0.8f),
        stop(0f, 0.6f)
      )),
      PropertyFactory.iconPitchAlignment(Property.ANCHOR_MAP),
      PropertyFactory.iconAllowOverlap(true),
      PropertyFactory.iconIgnorePlacement(true)
    );
    layerIds.add(WAYPOINT_LAYER_ID);
    MapUtils.addLayerToMap(mapboxMap, waypointLayer, belowLayer);
  }
}
 
Example #10
Source Project: mapbox-plugins-android   Author: mapbox   File: CircleManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testInitialization() {
  circleManager = new CircleManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  verify(style).addSource(geoJsonSource);
  verify(style).addLayer(circleLayer);
  assertTrue(circleManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : circleManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(circleLayer).setProperties(circleManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(circleLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #11
Source Project: mapbox-plugins-android   Author: mapbox   File: CircleManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testGeoJsonOptionsInitialization() {
  circleManager = new CircleManager(mapView, mapboxMap, style, coreElementProvider, null, geoJsonOptions, draggableAnnotationController);
  verify(style).addSource(optionedGeoJsonSource);
  verify(style).addLayer(circleLayer);
  assertTrue(circleManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : circleManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(circleLayer).setProperties(circleManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(circleLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(optionedGeoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #12
Source Project: mapbox-plugins-android   Author: mapbox   File: CircleManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCircleLayerFilter() {
  circleManager = new CircleManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  Expression expression = Expression.eq(Expression.get("test"), "selected");
  verify(circleLayer, times(0)).setFilter(expression);

  circleManager.setFilter(expression);
  verify(circleLayer, times(1)).setFilter(expression);

  when(circleLayer.getFilter()).thenReturn(expression);
  assertEquals(expression, circleManager.getFilter());
  assertEquals(expression, circleManager.layerFilter);
}
 
Example #13
Source Project: mapbox-plugins-android   Author: mapbox   File: FillManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testInitialization() {
  fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  verify(style).addSource(geoJsonSource);
  verify(style).addLayer(fillLayer);
  assertTrue(fillManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : fillManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(fillLayer).setProperties(fillManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(fillLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #14
Source Project: mapbox-plugins-android   Author: mapbox   File: FillManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testGeoJsonOptionsInitialization() {
  fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, geoJsonOptions, draggableAnnotationController);
  verify(style).addSource(optionedGeoJsonSource);
  verify(style).addLayer(fillLayer);
  assertTrue(fillManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : fillManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(fillLayer).setProperties(fillManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(fillLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(optionedGeoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #15
Source Project: mapbox-plugins-android   Author: mapbox   File: FillManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testFillLayerFilter() {
  fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  Expression expression = Expression.eq(Expression.get("test"), "selected");
  verify(fillLayer, times(0)).setFilter(expression);

  fillManager.setFilter(expression);
  verify(fillLayer, times(1)).setFilter(expression);

  when(fillLayer.getFilter()).thenReturn(expression);
  assertEquals(expression, fillManager.getFilter());
  assertEquals(expression, fillManager.layerFilter);
}
 
Example #16
Source Project: mapbox-plugins-android   Author: mapbox   File: SymbolManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testInitialization() {
  symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  verify(style).addSource(geoJsonSource);
  verify(style).addLayer(symbolLayer);
  assertTrue(symbolManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : symbolManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(symbolLayer).setProperties(symbolManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(symbolLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #17
Source Project: mapbox-plugins-android   Author: mapbox   File: SymbolManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testGeoJsonOptionsInitialization() {
  symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, geoJsonOptions, draggableAnnotationController);
  verify(style).addSource(optionedGeoJsonSource);
  verify(style).addLayer(symbolLayer);
  assertTrue(symbolManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : symbolManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(symbolLayer).setProperties(symbolManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(symbolLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(optionedGeoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #18
Source Project: mapbox-plugins-android   Author: mapbox   File: SymbolManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testSymbolLayerFilter() {
  symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  Expression expression = Expression.eq(Expression.get("test"), "selected");
  verify(symbolLayer, times(0)).setFilter(expression);

  symbolManager.setFilter(expression);
  verify(symbolLayer, times(1)).setFilter(expression);

  when(symbolLayer.getFilter()).thenReturn(expression);
  assertEquals(expression, symbolManager.getFilter());
  assertEquals(expression, symbolManager.layerFilter);
}
 
Example #19
Source Project: mapbox-plugins-android   Author: mapbox   File: LineManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testInitialization() {
  lineManager = new LineManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  verify(style).addSource(geoJsonSource);
  verify(style).addLayer(lineLayer);
  assertTrue(lineManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : lineManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(lineLayer).setProperties(lineManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(lineLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(geoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #20
Source Project: mapbox-plugins-android   Author: mapbox   File: LineManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testGeoJsonOptionsInitialization() {
  lineManager = new LineManager(mapView, mapboxMap, style, coreElementProvider, null, geoJsonOptions, draggableAnnotationController);
  verify(style).addSource(optionedGeoJsonSource);
  verify(style).addLayer(lineLayer);
  assertTrue(lineManager.dataDrivenPropertyUsageMap.size() > 0);
  for (Boolean value : lineManager.dataDrivenPropertyUsageMap.values()) {
    assertFalse(value);
  }
  verify(lineLayer).setProperties(lineManager.constantPropertyUsageMap.values().toArray(new PropertyValue[0]));
  verify(lineLayer, times(0)).setFilter(any(Expression.class));
  verify(draggableAnnotationController).onSourceUpdated();
  verify(optionedGeoJsonSource).setGeoJson(any(FeatureCollection.class));
}
 
Example #21
Source Project: mapbox-plugins-android   Author: mapbox   File: LineManagerTest.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testLineLayerFilter() {
  lineManager = new LineManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
  Expression expression = Expression.eq(Expression.get("test"), "selected");
  verify(lineLayer, times(0)).setFilter(expression);

  lineManager.setFilter(expression);
  verify(lineLayer, times(1)).setFilter(expression);

  when(lineLayer.getFilter()).thenReturn(expression);
  assertEquals(expression, lineManager.getFilter());
  assertEquals(expression, lineManager.layerFilter);
}
 
Example #22
Source Project: mapbox-plugins-android   Author: mapbox   File: TrafficPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
static Expression getLineColorFunction(@ColorInt int low, @ColorInt int moderate, @ColorInt int heavy,
                                       @ColorInt int severe) {
  return match(get("congestion"), Expression.color(Color.TRANSPARENT),
    stop("low", Expression.color(low)),
    stop("moderate", Expression.color(moderate)),
    stop("heavy", Expression.color(heavy)),
    stop("severe", Expression.color(severe)));
}
 
Example #23
Source Project: AirMapSDK-Android   Author: airmap   File: AirMapMapView.java    License: Apache License 2.0 5 votes vote down vote up
public void highlight(AirMapAdvisory advisory) {
    RectF mapRectF = new RectF(getLeft(), getTop(), getRight(), getBottom());
    Expression filter = Expression.has("id");
    List<Feature> selectedFeatures = getMap().queryRenderedFeatures(mapRectF, filter);

    for (Feature feature : selectedFeatures) {
        if (advisory.getId().equals(feature.getStringProperty("id"))) {
            mapStyleController.highlight(feature, advisory);
            zoomToFeatureIfNecessary(feature);
            break;
        }
    }
}
 
Example #24
Source Project: AirMapSDK-Android   Author: airmap   File: MapStyleController.java    License: Apache License 2.0 5 votes vote down vote up
public void hideInactiveAirspace(){
    Expression hasActive = Expression.has("active");
    Expression activeIsTrue = Expression.eq(Expression.get("active"), true);
    Expression active = Expression.all(hasActive, activeIsTrue);
    map.getMap().getStyle(style -> {
        for(Layer layer : Objects.requireNonNull(style.getLayers())){
            if(layer.getId().contains("airmap")){
                if(layer instanceof FillLayer){
                    if(((FillLayer) layer).getFilter() != null){
                        ((FillLayer) layer).setFilter(Expression.any(((FillLayer) layer).getFilter(), active));
                    } else {
                        ((FillLayer) layer).setFilter(active);
                    }

                } else if (layer instanceof  LineLayer){
                    if(((LineLayer) layer).getFilter() != null){
                        ((LineLayer) layer).setFilter(Expression.any(((LineLayer) layer).getFilter(), active));
                    } else {
                        ((LineLayer) layer).setFilter(active);
                    }

                } else if(layer instanceof  SymbolLayer){
                    if(((SymbolLayer) layer).getFilter() != null){
                        ((SymbolLayer) layer).setFilter(Expression.any(((SymbolLayer) layer).getFilter(), active));
                    } else {
                        ((SymbolLayer) layer).setFilter(active);
                    }

                } else {
                    Timber.e("Unknown layer");

                }
            }
        }
    });
}
 
Example #25
Source Project: deltachat-android   Author: deltachat   File: FilterProvider.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Expression getTimeFilter() {
    if (expressions.get(LAST_POSITION) != null) {
        return expressions.get(LAST_POSITION);
    } else if (expressions.get(RANGE) != null) {
        return expressions.get(RANGE);
    }

    return all();
}
 
Example #26
Source Project: deltachat-android   Author: deltachat   File: MapDataManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void initInfoWindowLayer() {
    Expression iconOffset = switchCase(
            toBool(get(LAST_LOCATION)), literal(new Float[] {-2f, -25f}),
            literal(new Float[] {-2f, -20f}));
    GeoJsonSource infoWindowSource = new GeoJsonSource(INFO_WINDOW_SRC);
    mapboxStyle.addSource(infoWindowSource);
    mapboxStyle.addLayer(new SymbolLayer(INFO_WINDOW_LAYER, INFO_WINDOW_SRC).withProperties(
            iconImage(INFO_WINDOW_ID),
            iconAnchor(ICON_ANCHOR_BOTTOM_LEFT),
                 /* all info window and marker image to appear at the same time*/
            iconAllowOverlap(true),
                /* offset the info window to be above the marker */
            iconOffset(iconOffset)
    ));
}
 
Example #27
Source Project: mapbox-plugins-android   Author: mapbox   File: CircleManager.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set filter on the managed circles.
 *
 * @param expression expression
 */
 @Override
public void setFilter(@NonNull Expression expression) {
  layerFilter = expression;
  layer.setFilter(layerFilter);
}
 
Example #28
Source Project: mapbox-plugins-android   Author: mapbox   File: FillManager.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set filter on the managed fills.
 *
 * @param expression expression
 */
 @Override
public void setFilter(@NonNull Expression expression) {
  layerFilter = expression;
  layer.setFilter(layerFilter);
}
 
Example #29
Source Project: mapbox-plugins-android   Author: mapbox   File: SymbolManager.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set filter on the managed symbols.
 *
 * @param expression expression
 */
 @Override
public void setFilter(@NonNull Expression expression) {
  layerFilter = expression;
  layer.setFilter(layerFilter);
}
 
Example #30
Source Project: mapbox-plugins-android   Author: mapbox   File: LineManager.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set filter on the managed lines.
 *
 * @param expression expression
 */
 @Override
public void setFilter(@NonNull Expression expression) {
  layerFilter = expression;
  layer.setFilter(layerFilter);
}