ArrowLineLayer extends KujakuLayer { private void createArrowHeadLayer() { arrowHeadLayer = new SymbolLayer(ARROW_HEAD_LAYER_ID, ARROW_HEAD_LAYER_SOURCE_ID); arrowHeadLayer.withProperties( PropertyFactory.iconImage(ARROW_HEAD_ICON), iconAllowOverlap(true), iconIgnorePlacement(true), PropertyFactory.iconSize(interpolate(linear(), zoom(), stop(MIN_ARROW_ZOOM, MIN_ZOOM_ARROW_HEAD_SCALE), stop(MAX_ARROW_ZOOM, MAX_ZOOM_ARROW_HEAD_SCALE) ) ), PropertyFactory.iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP), PropertyFactory.iconRotate(get(ARROW_HEAD_BEARING)), PropertyFactory.iconOpacity(1f) ); } private  ArrowLineLayer(@NonNull Builder builder); LineLayer getLineLayer(); SymbolLayer getArrowHeadLayer(); @Override void addLayerToMap(@NonNull MapboxMap mapboxMap); @Override void enableLayerOnMap(@NonNull MapboxMap mapboxMap); @Override void disableLayerOnMap(@NonNull MapboxMap mapboxMap); @Override @NonNull String[] getLayerIds(); @Override boolean removeLayerOnMap(@NonNull MapboxMap mapboxMap); @Override void updateFeatures(@NonNull FeatureCollection featureCollection); static Point getCenter(@NonNull Geometry featureGeometry); @Override FeatureCollection getFeatureCollection(); static final String ARROW_HEAD_BEARING; static final int MIN_ARROW_ZOOM; static final int MAX_ARROW_ZOOM; static final float MIN_ZOOM_ARROW_HEAD_SCALE; static final float MAX_ZOOM_ARROW_HEAD_SCALE; }
@Test public void createArrowHeadLayer() throws InvalidArrowLineConfigException { ArrayList<Feature> featuresList = new ArrayList<>(); FeatureCollection featureCollection = FeatureCollection.fromFeatures(featuresList); FeatureFilter.Builder builder = new FeatureFilter.Builder(featureCollection) .whereEq("type", "building"); ArrowLineLayer.FeatureConfig featureConfig = new ArrowLineLayer.FeatureConfig(builder); ArrowLineLayer.SortConfig sortConfig = new ArrowLineLayer.SortConfig("", ArrowLineLayer.SortConfig.SortOrder.DESC, ArrowLineLayer.SortConfig.PropertyType.NUMBER); ArrowLineLayer arrowLineLayer = new ArrowLineLayer.Builder(context, featureConfig, sortConfig).build(); assertNull((SymbolLayer) ReflectionHelpers.getField(arrowLineLayer, "arrowHeadLayer")); ReflectionHelpers.callInstanceMethod(arrowLineLayer, "createArrowHeadLayer"); SymbolLayer arrowHeadLayer = (SymbolLayer) ReflectionHelpers.getField(arrowLineLayer, "arrowHeadLayer"); assertNotNull(arrowHeadLayer); ShadowLayer shadowLayer = (ShadowLayer) Shadow.extract(arrowHeadLayer); HashMap<String, PropertyValue> propertyValueHashMap = shadowLayer.getPropertyValues(); assertEquals(7, propertyValueHashMap.size()); assertEquals(1f, propertyValueHashMap.get("icon-opacity").value); assertTrue(propertyValueHashMap.get("icon-rotate").toString().contains("arrow-head-bearing")); assertEquals("map", propertyValueHashMap.get("icon-rotation-alignment").value); assertEquals(true, propertyValueHashMap.get("icon-allow-overlap").value); assertEquals(true, propertyValueHashMap.get("icon-ignore-placement").value); }