Adds a direction link type to gorriecoe/silverstripe-link. Allowing editor to select a location on google maps, that will then produce a google maps direction link.
Composer is the recommended way of installing SilverStripe modules.
composer require gorriecoe/silverstripe-directionslink
Directions link uses GoogleMapField. So you will need to configure this in your config.yml.
BetterBrief\GoogleMapField:
default_options:
api_key: '[google-api-key]'
For more information check out BetterBrief\GoogleMapField.
Below are examples of link output:
Below is a basic example that can be added to the frontend of your project to detect apple devices and open the link in apple maps instead.
var googlemapsurl = "https://maps.google.com/maps:";
var links = document.querySelectorAll('a[href*="' + googlemapsurl +'"]'), i;
for (i = 0; i < links.length; ++i) {
links[i].addEventListener("click", function(event) {
event.preventDefault();
var link = this.getAttribute("href");
if ((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1)) {
link.replace(googlemapsurl, "maps://maps.apple.com/");
}
window.open(link);
});
}
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem