Hello, I need to use GoogleMap inside a Dialog.
First time everything is fine, when I close the Dialog and try to reopen
I get this message “TypeError: Cannot read property ‘click’ of undefined”
and the Marker doesn’t show. Please note that there is no real navigation.
Any help will be appreciated. Thanks in advance.
GoogleMap gmaps;
Dialog dialog = null;
public MainView() {
Button btnOpen = new Button("Open Dialog");
Button btnClose = new Button("Close");
btnClose.addClickListener(e -> {
dialog.close();
});
btnOpen.addClickListener(e -> {
gmaps = new GoogleMap(apiKey, null, null);
gmaps.setMapType(GoogleMap.MapType.SATELLITE);
gmaps.setSizeFull();
gmaps.setCenter(new LatLon(-31.636036, -60.7055271));
gmaps.addMarker("Center", new LatLon(-31.636036, -60.7055271), true, "");
dialog = new Dialog();
dialog.setSizeFull();
dialog.add(btnClose, gmaps);
dialog.open();
});
add(btnOpen);
}
A silly hint: I noticed that the problem is solved by invalidating the Vaadin Session. Maybe a method should be provided to force GoogleMap initialization ?
Button btnInit = new Button("ReInit");
btnInit.addClickListener(e -> VaadinSession.getCurrent().getSession().invalidate());
add(btnInit);