Skip to content

Commit 21fe068

Browse files
paodbjavier-godoy
authored andcommitted
feat(demo): add new demo for marker's drag end event
1 parent dc1c95a commit 21fe068

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.flowingcode.vaadin.addons.googlemaps;
2+
3+
import com.flowingcode.vaadin.addons.demo.DemoSource;
4+
import com.flowingcode.vaadin.addons.googlemaps.GoogleMap.MapType;
5+
import com.vaadin.flow.component.html.H2;
6+
import com.vaadin.flow.component.notification.Notification;
7+
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
8+
import com.vaadin.flow.router.PageTitle;
9+
10+
@PageTitle("Draggable Marker Demo")
11+
@DemoSource(
12+
"https://github.com/FlowingCode/GoogleMapsAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/googlemaps/DraggableMarkerDemo.java")
13+
@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+
}
36+
}
37+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public GooglemapsDemoView() {
3434
addDemo(new AddMarkersDemo());
3535
addDemo(new AddPolygonsDemo());
3636
addDemo(new GeolocationDemo());
37+
addDemo(new DraggableMarkerDemo());
3738
setSizeFull();
3839
}
3940
}

0 commit comments

Comments
 (0)