Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'click' of undefined when Map inside Dialog #2

Closed
BarneyIt opened this issue Apr 23, 2021 · 1 comment
Assignees

Comments

@BarneyIt
Copy link

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.
Sample Code to reproduce the problem:

public MainView() {
    GoogleMap gmaps;
    Dialog dialog = null;
    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);
}

@BarneyIt
Copy link
Author

BarneyIt commented May 3, 2021

The bug is in google-map-marker.js at the line 420 or so.
You have to change this piece of code:

  _clearListener(name) {
    if (this._listeners[name]) {
      google.maps.event.removeListener(this._listeners[name]);
      this._listeners[name] = null;
    }
  },

to this one:

  _clearListener(name) {
    if (this._listeners && this._listeners[name]) {
      google.maps.event.removeListener(this._listeners[name]);
      this._listeners[name] = null;
    }
  },

@BarneyIt BarneyIt closed this as completed May 3, 2021
@javier-godoy javier-godoy reopened this May 3, 2021
@paodb paodb self-assigned this May 3, 2021
@javier-godoy javier-godoy transferred this issue from FlowingCode/GoogleMapsAddon May 3, 2021
paodb added a commit that referenced this issue May 3, 2021
@paodb paodb moved this to Done in Flowing Code Addons May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants