|
2 | 2 |
|
3 | 3 | import com.flowingcode.vaadin.addons.demo.DemoSource; |
4 | 4 | import com.flowingcode.vaadin.addons.googlemaps.GoogleMap.MapType; |
5 | | -import com.vaadin.flow.component.html.H2; |
6 | 5 | import com.vaadin.flow.component.notification.Notification; |
7 | | -import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
8 | 6 | import com.vaadin.flow.router.PageTitle; |
9 | 7 |
|
10 | 8 | @PageTitle("Draggable Marker Demo") |
11 | 9 | @DemoSource( |
12 | 10 | "https://github.com/FlowingCode/GoogleMapsAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/googlemaps/DraggableMarkerDemo.java") |
13 | 11 | @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); |
36 | 27 | } |
37 | 28 | } |
0 commit comments