0
1
Fork 0
hedera-web-mindshore/package/usr/share/hedera-web/modules/location/location.js

156 lines
3.1 KiB
JavaScript
Raw Normal View History

var gmapsIsLoaded = false;
Vn.Location = new Class
({
Extends: Vn.Module
,activate: function ()
{
this.gui.loaderPush ();
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 ();
}
,gmapsLoaded: function ()
{
this.gui.loaderPop ();
gmapsIsLoaded = true;
var locations = [
{
lat: 39.436596
,lng: -0.351297
,title: 'Mercavalencia'
,desc: [
'Carretera Font D\'Encorts, 231'
,'46013 Valencia'
,'Valencia'
,'963 677 177'
]
,lang: null
},{
lat: 39.359785
,lng: -0.421772
,title: 'Valencia'
,desc: [
'Avenida Espioca, 100'
,'46460 Silla'
,'Valencia'
,'963 242 100'
]
,lang: 'es'
},{
lat: 40.4523125
,lng: -3.4984233
,title: 'Madrid'
,desc: [
'Polígono Industrial'
,'Calle de los Montes de Toledo, 20'
,'28830 San Fernando de Henares'
,'Madrid'
,'916 774 777'
]
},{
lat: 41.4962045
,lng: 2.3765504
,title: 'Barcelona'
,desc: [
'Camí del crist, 33'
,'08340 Vilassar de Mar'
,'Barcelona'
,'607 562 391'
]
,lang: 'ca'
},{
lat: 52.2612312
,lng: 4.7818154
,title: 'Holland'
,desc: [
'Aalsmeer Flower Auction'
,'Legmeerdijk 313'
,'1430 BA Aalsmeer'
,'Nederland'
]
,lang: 'nl'
},{
lat: 43.4375416
,lng: 5.2261456
,title: 'Marseille'
,desc: [
'ruben@verdnatura.es'
,'0033 781 533 900'
]
,lang: 'fr'
}
];
var options = {
zoom: 5
,mapTypeId: google.maps.MapTypeId.ROADMAP
,center: new google.maps.LatLng (46.0, 4.0)
};
var div = document.getElementById ('location');
var gmap = new google.maps.Map (div, options);
for (var i = 0; i < locations.length; i++)
this.createMarker (locations[i], gmap);
}
,createMarker: function (location, gmap)
{
var div = document.createElement ('div');
var h = document.createElement ('h3');
h.style.marginBottom = '8px';
h.appendChild (document.createTextNode (location.title));
div.appendChild (h);
for (i = 0; i < location.desc.length; i++)
{
var p = document.createElement ('p');
p.style.padding = '0px';
p.style.margin = '0px';
p.appendChild (document.createTextNode (location.desc[i]));
div.appendChild (p);
}
var lat = new google.maps.LatLng (
location.lat, location.lng);
var marker = new google.maps.Marker ({
position: lat
,tilte: location.title
,map: gmap
});
var infoWindow = new google.maps.InfoWindow ({
content: div
});
google.maps.event.addListener (marker, 'click',
this.openInfoWindow.bind (this, infoWindow, gmap, marker));
if (Vn.Cookie.get ('hedera_lang') == location.lang)
this.openInfoWindow (infoWindow, gmap, marker);
}
,openInfoWindow: function (infoWindow, gmap, marker)
{
if (this.openedWindow)
this.openedWindow.close ();
infoWindow.open (gmap, marker);
this.openedWindow = infoWindow;
}
});