From c77373e772d070475822d063f9c5d8e2179d63a6 Mon Sep 17 00:00:00 2001 From: Juan Date: Fri, 31 Aug 2018 08:14:47 +0200 Subject: [PATCH] Maps API key --- debian/changelog | 2 +- forms/cms/location/location.js | 113 ++++++++++++++++----------------- package.json | 2 +- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/debian/changelog b/debian/changelog index eec1ecb6..431c8e0d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.406.18) stable; urgency=low +hedera-web (1.406.19) stable; urgency=low * Initial Release. diff --git a/forms/cms/location/location.js b/forms/cms/location/location.js index dc823f5f..d98bd35b 100644 --- a/forms/cms/location/location.js +++ b/forms/cms/location/location.js @@ -1,116 +1,109 @@ var gmapsIsLoaded = false; -Hedera.Location = new Class -({ +Hedera.Location = new Class({ Extends: Hedera.Form ,locations: null - ,activate: function () - { - this.gui.loaderPush (); + ,activate: function() { + this.gui.loaderPush(); var sql = 'SELECT lat, lng, title, address, postcode, city, province, phone, language FROM location'; - this.conn.execQuery (sql, this.onLocationsDone.bind (this)); + this.conn.execQuery(sql, this.onLocationsDone.bind(this)); - if (!gmapsIsLoaded) - { - gmapsLoadedCallback = this.gmapsLoaded.bind (this); - Vn.includeJs ('https://maps.google.com/maps/api/js'+ - '?sensor=false&callback=gmapsLoadedCallback', null, true); - } - else - this.gmapsLoaded (); + if (!gmapsIsLoaded) { + gmapsLoadedCallback = this.gmapsLoaded.bind(this); + Vn.includeJs('https://maps.google.com/maps/api/js' + +'?sensor=false&callback=gmapsLoadedCallback' + +'&key=AIzaSyBbunFsAFEkjtw-c7BUHNgkThSlKEKFxiE', + null, true + ); + } else + this.gmapsLoaded(); } - ,onLocationsDone: function (resultSet) - { - this.locations = resultSet.fetchResult (); - this.allLoaded (); + ,onLocationsDone: function(resultSet) { + this.locations = resultSet.fetchResult(); + this.allLoaded(); } - ,gmapsLoaded: function () - { - this.gui.loaderPop (); + ,gmapsLoaded: function() { + this.gui.loaderPop(); gmapsIsLoaded = true; - this.allLoaded (); + this.allLoaded(); } - ,allLoaded: function () - { + ,allLoaded: function() { if (!this.locations || !gmapsIsLoaded) return; var options = { zoom: 4 ,mapTypeId: google.maps.MapTypeId.ROADMAP - ,center: new google.maps.LatLng (46.0, 4.0) + ,center: new google.maps.LatLng(46.0, 4.0) }; var div = this.$('form'); - var gmap = new google.maps.Map (div, options); + var gmap = new google.maps.Map(div, options); if (this.locations) - while (this.locations.next ()) - this.createMarker (this.locations, gmap); + while (this.locations.next()) + this.createMarker(this.locations, gmap); } - ,createMarker: function (location, gmap) - { - var div = document.createElement ('div'); + ,createMarker: function(location, gmap) { + var div = document.createElement('div'); div.className = 'marker'; - var h = document.createElement ('h3'); - h.appendChild (document.createTextNode (location.get ('title'))); - div.appendChild (h); + var h = document.createElement('h3'); + h.appendChild(document.createTextNode(location.get('title'))); + div.appendChild(h); - var p = document.createElement ('p'); - p.appendChild (document.createTextNode (location.get ('address'))); - div.appendChild (p); + var p = document.createElement('p'); + p.appendChild(document.createTextNode(location.get('address'))); + div.appendChild(p); - var p = document.createElement ('p'); - p.appendChild (document.createTextNode (location.get ('postcode') +' '+ location.get ('city'))); - div.appendChild (p); + var p = document.createElement('p'); + p.appendChild(document.createTextNode(location.get('postcode') +' '+ location.get('city'))); + div.appendChild(p); - var p = document.createElement ('p'); - p.appendChild (document.createTextNode (location.get ('province'))); - div.appendChild (p); + var p = document.createElement('p'); + p.appendChild(document.createTextNode(location.get('province'))); + div.appendChild(p); - var p = document.createElement ('p'); - p.appendChild (document.createTextNode (location.get ('phone'))); - div.appendChild (p); + var p = document.createElement('p'); + p.appendChild(document.createTextNode(location.get('phone'))); + div.appendChild(p); - var lat = new google.maps.LatLng ( - location.get ('lat'), - location.get ('lng') + var lat = new google.maps.LatLng( + location.get('lat'), + location.get('lng') ); - var marker = new google.maps.Marker ({ + var marker = new google.maps.Marker({ position: lat ,tilte: location.title ,map: gmap }); - var infoWindow = new google.maps.InfoWindow ({ + var infoWindow = new google.maps.InfoWindow({ content: div }); - google.maps.event.addListener (marker, 'click', - this.openInfoWindow.bind (this, infoWindow, gmap, marker)); + google.maps.event.addListener(marker, 'click', + this.openInfoWindow.bind(this, infoWindow, gmap, marker)); if (Vn.Locale.language - && Vn.Locale.language == location.get ('language')) - this.openInfoWindow (infoWindow, gmap, marker); + && Vn.Locale.language == location.get('language')) + this.openInfoWindow(infoWindow, gmap, marker); } - ,openInfoWindow: function (infoWindow, gmap, marker) - { + ,openInfoWindow: function(infoWindow, gmap, marker) { if (this.openedWindow) - this.openedWindow.close (); + this.openedWindow.close(); - infoWindow.open (gmap, marker); + infoWindow.open(gmap, marker); this.openedWindow = infoWindow; } }); - diff --git a/package.json b/package.json index 9a14553c..5ace6b76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.406.18", + "version": "1.406.19", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": {