Sfoglia il codice sorgente

Added iframe google maps with search query

Ricci Dorian 7 anni fa
parent
commit
da6b132f48
1 ha cambiato i file con 32 aggiunte e 0 eliminazioni
  1. 32 0
      tarteaucitron.services.js

+ 32 - 0
tarteaucitron.services.js

@@ -937,6 +937,38 @@ tarteaucitron.services.googlemaps = {
     }
 };
 
+// googlemaps search
+tarteaucitron.services.googlemapssearch = {
+    "key": "googlemapssearch",
+    "type": "api",
+    "name": "Google Maps Seard API",
+    "uri": "http://www.google.com/ads/preferences/",
+    "needConsent": true,
+    "cookies": ['nid'],
+    "js": function () {
+        "use strict";
+        tarteaucitron.fallback(['googlemapssearch'], function (x) {
+            var width = x.getAttribute("width"),
+                height = x.getAttribute("height"),
+                // url = x.getAttribute("data-url");
+                query = escape(x.getAttribute("data-search")),
+                key = x.getAttribute("data-api-key");
+            
+            // return '<iframe src="' + url + '" width="' + width + '" height="' + height + '" frameborder="0" scrolling="no" allowtransparency allowfullscreen></iframe>';
+            return '<iframe width="' + width +'" height="' + height + '" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q='+query+'&key='+key+'" allowfullscreen></iframe> '
+        });
+    },
+    "fallback": function () {
+        "use strict";
+        var id = 'googlemapssearch';
+        tarteaucitron.fallback(['googlemapssearch'], function (elem) {
+            elem.style.width = elem.getAttribute('width') + 'px';
+            elem.style.height = elem.getAttribute('height') + 'px';
+            return tarteaucitron.engage(id);
+        });
+    }
+};
+
 // google tag manager
 tarteaucitron.services.googletagmanager = {
     "key": "googletagmanager",