adding click to urls for the map markers
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 22 Oct 2019 17:20:14 +0000 (13:20 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 22 Oct 2019 17:20:14 +0000 (13:20 -0400)
glm-leaflet-theme.php
glm-map.js

index f3bc86e..d9401a2 100644 (file)
@@ -28,12 +28,15 @@ add_shortcode('glm-leaflet-theme', 'glm_leaflet_theme');
 
 function glm_enqueue_leaflet(){
     global $post;
-    if(has_shortcode($post->post_content,'glm-leaflet-theme')){
+    if($post && has_shortcode($post->post_content,'glm-leaflet-theme')){
         wp_enqueue_style('glm-leaflet-style', "https://unpkg.com/leaflet@1.3.3/dist/leaflet.css");
         wp_enqueue_script('glm-leaflet', "https://unpkg.com/leaflet@1.3.3/dist/leaflet.js");
         wp_enqueue_style('glm-leaflet-font', "https://fonts.googleapis.com/css?family=Montserrat&display=swap");
         wp_enqueue_style('glm-leaflet-gesture-style', "//unpkg.com/leaflet-gesture-handling/dist/leaflet-gesture-handling.min.css");
         wp_enqueue_script('glm-leaflet-gesture', "//unpkg.com/leaflet-gesture-handling");
+        ?>
+        <script> window.glm_memberdb_url = '<?php echo get_site_url() ?>/member-detail/';  </script>
+        <?php
         wp_enqueue_style('glm-leaflet-map-style', plugin_dir_url(__FILE__).'glm-map-style.css', '1.0.0',true);
         wp_enqueue_script('glm-leaflet-map', plugin_dir_url(__FILE__).'glm-map.js', array('jquery'), '1.0.0',true);
     }
index 45feb15..4af04a7 100644 (file)
@@ -36,8 +36,10 @@ jQuery(function($){
         var style = "color: #525252;line-height: 1;display: block; width: 130px; font-weight: bold; font-family: 'Montserrat';font-size: 15px;";
         //////////////////////
        
-        var boyne = new L.marker([45.2125, -85.0173]);
-        boyne.addTo(leafletMap);
+        var boyne = new L.marker([45.2125, -85.0173], {url: window.glm_memberdb_url});
+        boyne.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"boyne-city-clinic");
+        });
 
         new L.Marker([45.205, -85.015], {
             icon: new L.DivIcon({
@@ -48,8 +50,10 @@ jQuery(function($){
 
         //////////////////////
 
-        var chx = new L.marker([45.2984, -85.2558]);
-        chx.addTo(leafletMap);
+        var chx = new L.marker([45.2984, -85.2558], {url: window.glm_memberdb_url});
+        chx.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"charlevoix-clinic");
+        });;
 
         new L.Marker([45.289, -85.2558], {
             icon: new L.DivIcon({
@@ -60,8 +64,10 @@ jQuery(function($){
 
         //////////////////////
 
-        var cheboygan = new L.marker([45.605, -84.4848]);//opacity may be set to zero
-        cheboygan.addTo(leafletMap);
+        var cheboygan = new L.marker([45.605, -84.4848], {url: window.glm_memberdb_url});//opacity may be set to zero
+        cheboygan.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"cheboygan-clinic");
+        });
 
         new L.Marker([45.5972, -84.4848], {
             icon: new L.DivIcon({
@@ -72,8 +78,10 @@ jQuery(function($){
 
         //////////////////////
 
-        var harbor = new L.marker([45.4274, -84.9106]);
-        harbor.addTo(leafletMap);
+        var harbor = new L.marker([45.4274, -84.9106], {url: window.glm_memberdb_url});
+        harbor.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"harbor-springs-clinic");
+        });;
 
         new L.Marker([45.4274, -84.9106], {
             icon: new L.DivIcon({
@@ -84,8 +92,10 @@ jQuery(function($){
 
         ////////////////
 
-        var indianriver = new L.marker([45.4083, -84.6154]);
-        indianriver.addTo(leafletMap);
+        var indianriver = new L.marker([45.4083, -84.6154], {url: window.glm_memberdb_url});
+        indianriver.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"indian-river-clinic");
+        });;
 
 
         new L.Marker([45.40, -84.6154], {
@@ -97,8 +107,10 @@ jQuery(function($){
 
         ///////////
 
-        var petoskey = new L.marker([45.358, -85.0271]);
-        petoskey.addTo(leafletMap);
+        var petoskey = new L.marker([45.358, -85.0271], {url: window.glm_memberdb_url});
+        petoskey.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"petoskey-clinic");
+        });;
 
 
         new L.Marker([45.350, -85.0271], {
@@ -107,10 +119,13 @@ jQuery(function($){
                 html: '<span style="' + style + '" class="glm-theme-map-label">Petoskey</span>'
             })
         }).addTo(leafletMap);
+
         //////////////////////
 
-        var petoskeyEast = new L.marker([45.3746, -84.9276]);
-        petoskeyEast.addTo(leafletMap);
+        var petoskeyEast = new L.marker([45.3746, -84.9276], {url: window.glm_memberdb_url});
+        petoskeyEast.addTo(leafletMap).on("click", function(){
+            window.open(this.options.url+"petoskey-east-clinic");
+        });;
 
         new L.Marker([45.370, -84.9276], {
             icon: new L.DivIcon({