diff --git a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/PropertyFactory.java b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/PropertyFactory.java index 2fd97bff35d..6bb73c6ddfb 100644 --- a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/PropertyFactory.java +++ b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/PropertyFactory.java @@ -2047,6 +2047,16 @@ public static PropertyValue iconRotate(Expression value) { return new LayoutPropertyValue<>("icon-rotate", value); } + /** + * Size of additional area round the icon bounding box used for detecting symbol collisions. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue iconPadding(Float value) { + return new LayoutPropertyValue<>("icon-padding", value); + } + /** * Size of additional area round the icon bounding box used for detecting symbol collisions. * diff --git a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property_factory.java.ejs b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property_factory.java.ejs index 769e9f4ce9c..6730ff5834e 100644 --- a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property_factory.java.ejs +++ b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/style/layers/property_factory.java.ejs @@ -90,6 +90,18 @@ public class PropertyFactory { return new LayoutPropertyValue<>("<%- property.name %>", value); } +<% } -%> +<% if (property.type === 'padding') { -%> + /** + * <%- propertyFactoryMethodDoc(property) %> + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue <%- camelizeWithLeadingLowercase(property.name) %>(Float value) { + return new LayoutPropertyValue<>("<%- property.name %>", value); + } + <% } -%> /** * <%- propertyFactoryMethodDoc(property) %> diff --git a/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/SymbolLayerTest.java b/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/SymbolLayerTest.java index 7987d674591..425038418d1 100644 --- a/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/SymbolLayerTest.java @@ -425,6 +425,10 @@ public void testIconPaddingAsConstant() { Float[] propertyValue = {2.0f, 2.0f, 2.0f, 2.0f}; layer.setProperties(iconPadding(propertyValue)); assertEquals(layer.getIconPadding().getValue(), propertyValue); + // Single number value can be used too for backward compatibility + Float number = propertyValue[0] + 1.0f; + layer.setProperties(iconPadding(number)); + assertEquals(layer.getIconPadding().getValue(), new Float[]{number, number, number, number}); } @Test diff --git a/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/layer.junit.ejs b/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/layer.junit.ejs index f16691afcca..6d53209a1c3 100644 --- a/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/layer.junit.ejs +++ b/platform/android/MapLibreAndroidTestApp/src/androidTest/java/org/maplibre/android/testapp/style/layer.junit.ejs @@ -232,6 +232,12 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest { <% } -%> layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue)); assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue); +<% if (property.type === 'padding') { -%> + // Single number value can be used too for backward compatibility + Float number = propertyValue[0] + 1.0f; + layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(number)); + assertEquals(layer.get<%- camelize(property.name) %>().getValue(), new Float[]{number, number, number, number}); +<% } -%> <% if (property.tokens) { -%> layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));