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

Error in dynamicmap.js: this._markerClick is not a function #49

Closed
MoritzLost opened this issue Mar 30, 2022 · 3 comments
Closed

Error in dynamicmap.js: this._markerClick is not a function #49

MoritzLost opened this issue Mar 30, 2022 · 3 comments
Labels
Bug Report Something isn't working

Comments

@MoritzLost
Copy link

I'm trying to initialize an info window in JavaScript, but it's not working correctly. In 4.1.1, the following code worked fine (simplified to relevant parts):

const marker = {
    id: `marker-lat-lng-123,456`,
    lat: 123,
    lng: 456,
};
const infoWindowHtml = '<p>the title</p>';
map.markers(marker, {
    infoWindowOptions: {
        content: infoWindowHtml,
    },
})

While this doesn't cause any errors, the info window doesn't open when the marker is clicked. I tried to attach an event listener to open it manually using the markerClick option, at which point I get the following error message in the console:

Uncaught (in promise) TypeError: this._markerClick is not a function
markers dynamicmap.js:174

Indeed it looks like the _markerClick function doesn't exist anymore in dynamicmap.js. I checked the JS file in 4.1.1, which still includes the _markerClick function. Regression bug?

In addition to this bug, what is the 'correct' way to attach simple info windows to markers in 4.1.5?

  • PHP 8.1.3
  • Craft 3.7.37
  • Google Maps 4.1.5
@lindseydiloreto
Copy link
Collaborator

Definitely a regression bug. Good catch, thanks for reporting it!

I'll follow up with you via Discord DM to resolve this and #48.

@lindseydiloreto lindseydiloreto added the Bug Report Something isn't working label Mar 30, 2022
@MoritzLost
Copy link
Author

@lindseydiloreto Thanks! I've tried the latest branch and it does fix the error message – but I still can't get the info window to show up. I've tried to show all info windows just to test if they're being created at all, but it looks like they aren't:

const marker = {
    id: `marker-lat-lng-123,456`,
    lat: 123,
    lng: 456,
};
const infoWindowHtml = '<p>the title</p>';
map.markers(marker, {
    infoWindowOptions: {
        content: infoWindowHtml,
    },
    markerClick: () => map.openInfoWindow('*'),
})

This doesn't do anything. I've also put some logging inside dynamicmap.js just to check, looks like this._infoWindows is completely empty, even after calling the map.markers with the infoWindowOptions shown above. I've looked through the 4.1.1 branch again, in this version, the map.markers function included some code to attach the info window. Those lines are gone in 4.1.5, so maybe the info windows aren't being attached at all?

@lindseydiloreto
Copy link
Collaborator

This is now fixed in v4.1.6. Thanks again for reporting it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants