Skip to content

Commit bcc3ec6

Browse files
paodbjavier-godoy
authored andcommitted
fix(demo): make DraggableMarkerDemo extend AbstractGoogleMapsDemo
1 parent effb22c commit bcc3ec6

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/test/java/com/flowingcode/vaadin/addons/googlemaps/DraggableMarkerDemo.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,27 @@
22

33
import com.flowingcode.vaadin.addons.demo.DemoSource;
44
import com.flowingcode.vaadin.addons.googlemaps.GoogleMap.MapType;
5-
import com.vaadin.flow.component.html.H2;
65
import com.vaadin.flow.component.notification.Notification;
7-
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
86
import com.vaadin.flow.router.PageTitle;
97

108
@PageTitle("Draggable Marker Demo")
119
@DemoSource(
1210
"https://github.com/FlowingCode/GoogleMapsAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/googlemaps/DraggableMarkerDemo.java")
1311
@SuppressWarnings("serial")
14-
public class DraggableMarkerDemo extends VerticalLayout {
15-
16-
public DraggableMarkerDemo() {
17-
this.setSizeFull();
18-
String apiKey = System.getProperty("google.maps.api");
19-
if (apiKey == null) {
20-
add(
21-
new H2(
22-
"Api key is needded to run the demo, pass it using the following system property: '-Dgoogle.maps.api=<your-api-key>'"));
23-
} else {
24-
GoogleMap gmaps = new GoogleMap(apiKey, null, null);
25-
gmaps.setMapType(MapType.ROADMAP);
26-
gmaps.setSizeFull();
27-
gmaps.setCenter(new LatLon(-31.636036, -60.7055271));
28-
29-
gmaps.addMarker("Center", gmaps.getCenter(), true, Markers.PURPLE)
30-
.addDragEndEventListener(
31-
e ->
32-
Notification.show("Lat: " + e.getLatitude() + " - Lng: " + e.getLongitude()));
33-
34-
add(gmaps);
35-
}
12+
public class DraggableMarkerDemo extends AbstractGoogleMapsDemo {
13+
14+
@Override
15+
protected void createGoogleMapsDemo(String apiKey) {
16+
GoogleMap gmaps = new GoogleMap(apiKey, null, null);
17+
gmaps.setMapType(MapType.ROADMAP);
18+
gmaps.setSizeFull();
19+
gmaps.setCenter(new LatLon(-31.636036, -60.7055271));
20+
21+
gmaps.addMarker("Center", gmaps.getCenter(), true, Markers.PURPLE)
22+
.addDragEndEventListener(
23+
e ->
24+
Notification.show("Lat: " + e.getLatitude() + " - Lng: " + e.getLongitude()));
25+
26+
add(gmaps);
3627
}
3728
}

0 commit comments

Comments
 (0)