Closed idawgik closed 2 years ago
Not sure if this is exactly the problem, but try chaining the openInfoWindow
parameter right after the zoom
parameter...
{{ googleMaps.map(address, {
'id': 'footer-map',
'height': 500,
'styles': styleSet,
'infoWindowTemplate': '_layout/_info_window'
})
.zoom(17)
.openInfoWindow('*')
.tag()
}}
If that doesn't do the trick, ping me on Craft Discord, it'll be easier to troubleshoot it together there. If the solution is notable, we can circle back and post the answer in this thread.
Got this resolved over Discord. Had to put the code to open the info window in a callback on the .tag() method.
Working code:
{% set address = contactInformation.location.location %}
{{ googleMaps.map(address, {
'id': 'footer-map',
'height': 500,
'styles': styleSet,
'infoWindowTemplate': '_layout/_info_window'
}).zoom(17).tag({
'callback': 'openInfoWindow'
}) }}
{% js %}
function openInfoWindow(){
var map = googleMaps.getMap('footer-map');
map.openInfoWindow('*');
}
{% endjs %}
Thanks for the help!
Awesome, no problem! Feel free to ping me on Discord in the future, it's the easiest way to reach me. 🙂
Hey, so I have a map with a single marker that I want to open the info window by default on page load.
I see the documented function here: https://plugins.doublesecretagency.com/google-maps/dynamic-maps/universal-methods/#openinfowindow-markerid
However, I am unable to get it to actually work in my code and not sure what I'm doing wrong.
Here's my twig code:
It doesn't seem to actually run the map.openInfoWindow function. I've also tried doing this with javascript, however it seems the scripts the Google Maps plugin inserts on the page are added AFTER any custom JS I add, so I'm unable to access the map since it's not loaded yet.
I'm probably missing something obvious, but any assistance is appreciated.
I'm on Craft 4.0.5.2 with Google Maps 4.2.3