doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Add a `markerLink` option (similar to `infoWindowTemplate`) #34

Closed lindseydiloreto closed 2 years ago

lindseydiloreto commented 3 years ago

Currently, it's possible to use the infoWindowTemplate option to make an info window open when you click on markers.

It would be nice if there were a markerLink option to make a marker clickable as a link...

{# Dynamically set each marker as a link to `entry.url` #}
{% set options = {
    'markerLink': '{url}'
} %}

Under the hood, it would operate very similarly to infoWindowTemplate...

// When marker is clicked, go to the entry's URL
google.maps.event.addListener(marker, 'click', function() {
    window.location.href = '{{ entry.url }}';
});

You obviously would not be able to use markerLink and infoWindowTemplate at the same time. One of these settings would override the other.

marflow commented 3 years ago

Very useful addition to the GoogleMaps plugin. Thanks a lot for turning that into reality so quickly! 💯

lindseydiloreto commented 3 years ago

Similarly... It would be great if we could trigger a JavaScript callback function when clicking on a marker.

Certain data would need to be passed into the callback (including the element's ID and/or handle).

google.maps.event.addListener(marker, 'click', callback(data));
lindseydiloreto commented 2 years ago

This is done, and will be formally released with v4.1.0. 👍

In the meantime, you can switch to the dev branch to get all the latest changes...

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

Check out the new On Marker Click docs to learn how to use the new markerLink and markerClick options.