From fa118aca960ec2a6915ccc55c02cfae1a0ca3d28 Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Thu, 16 May 2024 11:05:00 -0300 Subject: [PATCH 1/2] deprecate: deprecate addCustomControls method Use setCustomControls instead. Close #127 --- .../vaadin/addons/googlemaps/GoogleMap.java | 19 +++++++++++++++++++ .../addons/googlemaps/GeolocationDemo.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java index b42629d..8daf37b 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java +++ b/src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java @@ -747,7 +747,10 @@ public LatLonBounds getBounds() { * Adds custom control buttons to the map. * * @param customControls list of custom controls to add to the map + * + * @deprecated {@link #setCustomControls(CustomControl... customControls)} should be used instead. */ + @Deprecated public void addCustomControls(CustomControl... customControls) { JsonArray jsonArray = Json.createArray(); for (int i = 0; i < customControls.length; i++) { @@ -758,4 +761,20 @@ public void addCustomControls(CustomControl... customControls) { } this.getElement().setPropertyJson("customControls", jsonArray); } + + /** + * Sets the custom control buttons to be displayed in the map. + * + * @param customControls list of custom controls to add to the map + */ + public void setCustomControls(CustomControl... customControls) { + JsonArray jsonArray = Json.createArray(); + for (int i = 0; i < customControls.length; i++) { + CustomControl customControl = customControls[i]; + jsonArray.set(i, customControl.getJson(i)); + customControl.getControlButton().getElement().setAttribute("slot", "customControlSlot_" + i); + this.getElement().appendChild(customControl.getControlButton().getElement()); + } + this.getElement().setPropertyJson("customControls", jsonArray); + } } diff --git a/src/test/java/com/flowingcode/vaadin/addons/googlemaps/GeolocationDemo.java b/src/test/java/com/flowingcode/vaadin/addons/googlemaps/GeolocationDemo.java index a9fd1dc..84e2516 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/googlemaps/GeolocationDemo.java +++ b/src/test/java/com/flowingcode/vaadin/addons/googlemaps/GeolocationDemo.java @@ -52,7 +52,7 @@ protected void createGoogleMapsDemo(String apiKey) { currentLocationButton.setClassName("geolocation-button"); CustomControl geolocationControl = new CustomControl(currentLocationButton, ControlPosition.TOP_CENTER); - gmaps.addCustomControls(geolocationControl); + gmaps.setCustomControls(geolocationControl); gmaps.addCurrentLocationEventListener(e -> gmaps .addMarker(new GoogleMapMarker("You are here!", gmaps.getCenter(), false, Markers.GREEN))); From 543690af53c6a22367f8226c319facc4570d4571 Mon Sep 17 00:00:00 2001 From: Paola De Bartolo Date: Thu, 16 May 2024 11:05:41 -0300 Subject: [PATCH 2/2] build: update version to 1.13.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a21b1c..22f697a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.flowingcode.vaadin.addons google-maps - 1.12.1-SNAPSHOT + 1.13.0-SNAPSHOT Google Maps Addon Integration of google-map for Vaadin platform