Comments (5)
I've been looking into this issue, and it doesn't appear to be a bug at first glance. When Google Maps is in full screen mode, it makes its inner div occupy the entire screen, making everything outside of it not visible. You can find some explanations here & here.
To complicate matters further, a Vaadin dialog is an overlay, which means its behavior in full screen mode is uncertain.
One possible solution could be adding an API to toggle full screen mode, which might help with this use case. This post could be a useful starting point for that.
I will update the ticket if I find any solutions or workarounds.
from googlemapsaddon.
Hi @JariHanah. I found a way to know if the map is showing in fullScreen mode and make it go back to not fullScreen if you want a custom control button to open a dialog. Here's my example:
@Route("test")
public class MyTestView extends VerticalLayout {
private Boolean isFullScreen = false;
public MyTestView() {
this.setSizeFull();
GoogleMap gmaps = new GoogleMap("YOUR_API_KEY", null, null);
gmaps.setMapType(MapType.ROADMAP);
gmaps.setSizeFull();
add(gmaps);
Button openDialogButton = new Button("Open Dialog", e -> {
Dialog d = new Dialog(new Span("I'm a dialog"));
d.setWidth("150px");
d.setHeight("150px");
if (isFullScreen) { // if full screen is on, close it so dialog can be visible
this.closeFullScreen(gmaps);
}
d.open();
});
openDialogButton.getElement().getStyle().set("background", "white");
openDialogButton.getElement().getStyle().set("color", "black");
CustomControl customControl = new CustomControl(openDialogButton, ControlPosition.TOP_CENTER);
gmaps.setCustomControls(customControl);
// listen to fullscreenchange event to know if map is in full screen mode
gmaps.getElement().addEventListener("fullscreenchange", e -> {
gmaps.getElement()
.executeJs(
"var isFullScreen = document.fullScreen ||\r\n"
+ " document.mozFullScreen ||\r\n"
+ " document.webkitIsFullScreen;\r\n"
+ " return isFullScreen;")
.then(Boolean.class, this::setIsFullScreen);
});
}
public Boolean getIsFullScreen() {
return isFullScreen;
}
public void setIsFullScreen(Boolean isFullScreen) {
this.isFullScreen = isFullScreen;
}
// close full screen mode
private void closeFullScreen(GoogleMap map) {
if (isFullScreen) {
map.getElement().executeJs("document.exitFullScreen = true; document.exitFullscreen();");
}
}
}
We're still investigating and discussing what we should add in the component's API and what not so hope this helps to your use case at least for now.
from googlemapsaddon.
Beautiful, it worked!
from googlemapsaddon.
It was discussed on today's planning meeting and we will be adding to the API a way to know if the full screen is on and the possibility to close it programatically.
from googlemapsaddon.
Hello @JariHanah we added to the component a listener addFullScreenListener
to know if the map is being shown in full screen or not and a method to close it closeFullScreen
if it is in that mode. With that, the previous example can be done like this:
private boolean isFullScreen = false;
public MyTestView() {
this.setSizeFull();
GoogleMap gmaps = new GoogleMap("YOUR_API_KEY", null, null);
gmaps.setMapType(MapType.ROADMAP);
gmaps.setSizeFull();
add(gmaps);
Button openDialogButton = new Button("Open Dialog", e -> {
Dialog d = new Dialog(new Span("I'm a dialog"));
d.setWidth("150px");
d.setHeight("150px");
if (isFullScreen) {
// if full screen is on, close it so dialog can be visible
gmaps.closeFullScreen();
}
d.open();
});
openDialogButton.getElement().getStyle().set("background", "white");
openDialogButton.getElement().getStyle().set("color", "black");
CustomControl customControl = new CustomControl(openDialogButton, ControlPosition.TOP_CENTER);
gmaps.setCustomControls(customControl);
// add listener to know if full screen mode is on
gmaps.addFullScreenListener(e -> this.isFullScreen = e.isFullScreen());
}
This should be expected in version 2.0.0 that was not release yet. But we will inform you when is out.
from googlemapsaddon.
Related Issues (20)
- Add support for adding lines besides polygons
- Add a custom renderer for markers clustering
- removeMarker when clustering enabled not working
- Add support for clustering with custom marker images HOT 2
- Setting of anchorpoint for Markers HOT 1
- Add the 'current location' button HOT 4
- Add support for controls API HOT 2
- 'My location' marker
- PolyLine, Polygon, not first Map usage
- "google.maps.Marker is deprecated" warning HOT 1
- Add API to hide POI (point of interest) HOT 4
- New map styling is coming soon to Google Maps Platform
- Support for Directions
- Documentation for setClusteringRenderer HOT 4
- CustomControl Buttons are rePostioned! cant have different positions of multiple buttons! HOT 8
- Add/remove custom controls dynamically HOT 3
- Screen Shot Feature
- setZoom write attribute but getZoom read property HOT 1
- Internally manage trackLocationId
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from googlemapsaddon.