Giter Club home page Giter Club logo

Comments (5)

paodb avatar paodb commented on June 26, 2024 1

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.

paodb avatar paodb commented on June 26, 2024 1

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.

JariHanah avatar JariHanah commented on June 26, 2024 1

Beautiful, it worked!

from googlemapsaddon.

paodb avatar paodb commented on June 26, 2024

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.

paodb avatar paodb commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.