Maps API key

This commit is contained in:
Juan 2018-08-31 08:14:47 +02:00
parent 03dd6f94e4
commit c77373e772
3 changed files with 55 additions and 62 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.406.18) stable; urgency=low hedera-web (1.406.19) stable; urgency=low
* Initial Release. * Initial Release.

View File

@ -1,116 +1,109 @@
var gmapsIsLoaded = false; var gmapsIsLoaded = false;
Hedera.Location = new Class Hedera.Location = new Class({
({
Extends: Hedera.Form Extends: Hedera.Form
,locations: null ,locations: null
,activate: function () ,activate: function() {
{ this.gui.loaderPush();
this.gui.loaderPush ();
var sql = 'SELECT lat, lng, title, address, postcode, city, province, phone, language FROM location'; 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) if (!gmapsIsLoaded) {
{ gmapsLoadedCallback = this.gmapsLoaded.bind(this);
gmapsLoadedCallback = this.gmapsLoaded.bind (this); Vn.includeJs('https://maps.google.com/maps/api/js'
Vn.includeJs ('https://maps.google.com/maps/api/js'+ +'?sensor=false&callback=gmapsLoadedCallback'
'?sensor=false&callback=gmapsLoadedCallback', null, true); +'&key=AIzaSyBbunFsAFEkjtw-c7BUHNgkThSlKEKFxiE',
} null, true
else );
this.gmapsLoaded (); } else
this.gmapsLoaded();
} }
,onLocationsDone: function (resultSet) ,onLocationsDone: function(resultSet) {
{ this.locations = resultSet.fetchResult();
this.locations = resultSet.fetchResult (); this.allLoaded();
this.allLoaded ();
} }
,gmapsLoaded: function () ,gmapsLoaded: function() {
{ this.gui.loaderPop();
this.gui.loaderPop ();
gmapsIsLoaded = true; gmapsIsLoaded = true;
this.allLoaded (); this.allLoaded();
} }
,allLoaded: function () ,allLoaded: function() {
{
if (!this.locations || !gmapsIsLoaded) if (!this.locations || !gmapsIsLoaded)
return; return;
var options = { var options = {
zoom: 4 zoom: 4
,mapTypeId: google.maps.MapTypeId.ROADMAP ,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 div = this.$('form');
var gmap = new google.maps.Map (div, options); var gmap = new google.maps.Map(div, options);
if (this.locations) if (this.locations)
while (this.locations.next ()) while (this.locations.next())
this.createMarker (this.locations, gmap); this.createMarker(this.locations, gmap);
} }
,createMarker: function (location, gmap) ,createMarker: function(location, gmap) {
{ var div = document.createElement('div');
var div = document.createElement ('div');
div.className = 'marker'; div.className = 'marker';
var h = document.createElement ('h3'); var h = document.createElement('h3');
h.appendChild (document.createTextNode (location.get ('title'))); h.appendChild(document.createTextNode(location.get('title')));
div.appendChild (h); div.appendChild(h);
var p = document.createElement ('p'); var p = document.createElement('p');
p.appendChild (document.createTextNode (location.get ('address'))); p.appendChild(document.createTextNode(location.get('address')));
div.appendChild (p); div.appendChild(p);
var p = document.createElement ('p'); var p = document.createElement('p');
p.appendChild (document.createTextNode (location.get ('postcode') +' '+ location.get ('city'))); p.appendChild(document.createTextNode(location.get('postcode') +' '+ location.get('city')));
div.appendChild (p); div.appendChild(p);
var p = document.createElement ('p'); var p = document.createElement('p');
p.appendChild (document.createTextNode (location.get ('province'))); p.appendChild(document.createTextNode(location.get('province')));
div.appendChild (p); div.appendChild(p);
var p = document.createElement ('p'); var p = document.createElement('p');
p.appendChild (document.createTextNode (location.get ('phone'))); p.appendChild(document.createTextNode(location.get('phone')));
div.appendChild (p); div.appendChild(p);
var lat = new google.maps.LatLng ( var lat = new google.maps.LatLng(
location.get ('lat'), location.get('lat'),
location.get ('lng') location.get('lng')
); );
var marker = new google.maps.Marker ({ var marker = new google.maps.Marker({
position: lat position: lat
,tilte: location.title ,tilte: location.title
,map: gmap ,map: gmap
}); });
var infoWindow = new google.maps.InfoWindow ({ var infoWindow = new google.maps.InfoWindow({
content: div content: div
}); });
google.maps.event.addListener (marker, 'click', google.maps.event.addListener(marker, 'click',
this.openInfoWindow.bind (this, infoWindow, gmap, marker)); this.openInfoWindow.bind(this, infoWindow, gmap, marker));
if (Vn.Locale.language if (Vn.Locale.language
&& Vn.Locale.language == location.get ('language')) && Vn.Locale.language == location.get('language'))
this.openInfoWindow (infoWindow, gmap, marker); this.openInfoWindow(infoWindow, gmap, marker);
} }
,openInfoWindow: function (infoWindow, gmap, marker) ,openInfoWindow: function(infoWindow, gmap, marker) {
{
if (this.openedWindow) if (this.openedWindow)
this.openedWindow.close (); this.openedWindow.close();
infoWindow.open (gmap, marker); infoWindow.open(gmap, marker);
this.openedWindow = infoWindow; this.openedWindow = infoWindow;
} }
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "1.406.18", "version": "1.406.19",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {