Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate addCustomControls method and replace with setCustomControls #129

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.flowingcode.vaadin.addons</groupId>
<artifactId>google-maps</artifactId>
<version>1.12.1-SNAPSHOT</version>
<version>1.13.0-SNAPSHOT</version>
<name>Google Maps Addon</name>
<description>Integration of google-map for Vaadin platform</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
Loading