Skip to content

Commit 891da64

Browse files
committed
feat: add json-migration-helper
Close #169
1 parent d85c8fc commit 891da64

File tree

4 files changed

+76
-67
lines changed

4 files changed

+76
-67
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.flowingcode.vaadin.addons</groupId>
66
<artifactId>google-maps</artifactId>
7-
<version>2.3.1-SNAPSHOT</version>
7+
<version>2.4.0-SNAPSHOT</version>
88
<name>Google Maps Addon</name>
99
<description>Integration of google-map for Vaadin platform</description>
1010

@@ -132,6 +132,12 @@
132132
</exclusions>
133133
</dependency>
134134

135+
<dependency>
136+
<groupId>com.flowingcode.vaadin</groupId>
137+
<artifactId>json-migration-helper</artifactId>
138+
<version>0.0.1-SNAPSHOT</version>
139+
</dependency>
140+
135141
<dependency>
136142
<groupId>org.slf4j</groupId>
137143
<artifactId>slf4j-simple</artifactId>

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.ElementType;
2424
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.FeatureType;
2525
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.MapStyle;
26+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
2627
import com.vaadin.flow.component.ClickEvent;
2728
import com.vaadin.flow.component.ClientCallable;
2829
import com.vaadin.flow.component.Component;
@@ -518,7 +519,7 @@ public Registration addClickListener(ComponentEventListener<GoogleMapClickEvent>
518519
DomListenerRegistration registration =
519520
getElement()
520521
.addEventListener("google-map-click", ev -> {
521-
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
522+
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
522523
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
523524
}).addEventData("event.detail.latLng");
524525
return registration::remove;
@@ -530,12 +531,12 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
530531
DomListenerRegistration registration =
531532
getElement()
532533
.addEventListener("google-map-rightclick", ev -> {
533-
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
534+
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
534535
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
535536
}).addEventData("event.detail.latLng");
536537
return registration::remove;
537538
}
538-
539+
539540
/**
540541
* Sets current location on map using default geolocation options.
541542
*
@@ -545,13 +546,13 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
545546
public void goToCurrentLocation() {
546547
goToCurrentLocation(null);
547548
}
548-
549+
549550
/**
550551
* Sets current location on map using specific geolocation options.
551552
*
552553
* <p>Setting geolocation requires that the user gives consent to location sharing when prompted
553554
* by the browser.
554-
*
555+
*
555556
* @param options the geolocation options (enableHighAccuracy, timeout, maximumAge)
556557
*/
557558
public void goToCurrentLocation(GeolocationOptions options) {
@@ -623,7 +624,7 @@ public Registration addGeolocationErrorEventListener(
623624
ComponentEventListener<GeolocationErrorEvent> listener) {
624625
return addListener(GeolocationErrorEvent.class, listener);
625626
}
626-
627+
627628
/**
628629
* Activates tracking current location on map using default geolocation options.
629630
*
@@ -767,7 +768,7 @@ public Registration addGoogleMapBoundsChangedListener(
767768
DomListenerRegistration registration =
768769
getElement().addEventListener("google-map-bounds_changed", ev -> {
769770
listener.onComponentEvent(new GoogleMapBoundsChangedEvent(this, true,
770-
new LatLonBounds(ev.getEventData().get("event.detail"))));
771+
new LatLonBounds(JsonMigration.getEventData(ev).get("event.detail"))));
771772
}).debounce(1000, DebouncePhase.TRAILING).addEventData("event.detail");
772773
return registration::remove;
773774
}
@@ -803,7 +804,7 @@ public void addCustomControls(CustomControl... customControls) {
803804
customControl.getControlButton().getElement().setAttribute("slot", "customControlSlot_" + i);
804805
getElement().appendChild(customControl.getControlButton().getElement());
805806
}
806-
getElement().setPropertyJson("customControls", jsonArray);
807+
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
807808
}
808809

809810
/**
@@ -822,7 +823,7 @@ public void setCustomControls(CustomControl... customControls) {
822823
getElement().appendChild(customControl.getControlButton().getElement());
823824
this.customControls.add(customControl);
824825
}
825-
getElement().setPropertyJson("customControls", jsonArray);
826+
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
826827
});
827828
}
828829

@@ -924,6 +925,6 @@ public void setMapStyle(MapStyle... mapStyles) {
924925
MapStyle mapStyle = mapStyles[i];
925926
jsonArray.set(i, mapStyle.getJson());
926927
}
927-
getElement().setPropertyJson("styles", jsonArray);
928+
JsonMigration.setPropertyJson(getElement(), "styles", jsonArray);
928929
}
929930
}

0 commit comments

Comments
 (0)