var map; var geocoder; var marker; var gmarkers = []; var arrplaces = []; var arrnear = []; var directionsService; var directionsDisplay; var swapped =0; var addressok; $(document).ready(function () { if ($('#map_canvas').length != 0) { loadAPI(); } }); function loadAPI() { //Load Google Api key on Load Call Initialise function var script = document.createElement("script"); script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyA9EWEjeg2F7wq8IqEBeESjG4yt33t6940&sensor=true®ion=GR&callback=initialise&language=gr&v=3.13"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); } function initialise() { directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer(); var mapOptions = { zoom: 13, center: new google.maps.LatLng(37.975555, 23.734707), mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false } map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); geocoder = new google.maps.Geocoder(); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById("directionsPanel")); if (arrplaces.length != 0) { addpois(arrplaces); } if (arrnear.length != 0) { addpois(arrnear); } } //id, section, name, address ,x, y, iconfile, distance, zindex function addpois(locations) { var lgicons = 0; var smicons = 0; var id; var section; var name; var address; var x; var y; var iconfile; var distance; var zindex; var iconsize; var placefile; var infowindow = new google.maps.InfoWindow({ content: '' }); var bounds = new google.maps.LatLngBounds(); for (var i = 0; i < locations.length; i++) { var place = locations[i]; id = place[0]; section = place[1]; name = place[2]; address = place[3]; x = place[4]; y = place[5]; iconfile = place[6]; distance = place[7]; zindex = place[8]; iconsize = place[9]; placefile = place[10]; var poihtml = infowindowhtml(id, section, name, address, distance, iconfile, placefile); if (iconsize == 1) { var image = new google.maps.MarkerImage('/images/map/icons/' + iconfile + '.png'); lgicons += 1; } else { var image = new google.maps.MarkerImage('/images/map/icons/' + iconfile + '.png', new google.maps.Size(40, 40), null, new google.maps.Point(10, 10), new google.maps.Size(20, 20) ); smicons += 1; } var myLatLng = new google.maps.LatLng(x, y); // marker = new google.maps.Marker({ // id : id, // position: myLatLng, // map: map, // icon: image, // optimized: false, // info: infowindowhtml(id, section, name, address, distance, iconfile, placefile) // }); //google.maps.event.addListener(marker, "click", function () { // infowindow.setContent(this.info); // infowindow.open(map, this); //}); //gmarkers.push(marker); //gmarkers[id] = marker; var html = '' + name + '' + address +'' setMarkers(map, myLatLng,html,i,locations.length,iconsize) bounds.extend(myLatLng); } if(gmarkers.length==1){ openmarkerwindow(0); //gmarkers[0].showInfoWindow(); }; if (iconsize == 2 && locations.length ===1) { var place = locations[0]; map.setCenter(new google.maps.LatLng(place[4], place[5])); map.setZoom(13); } else { map.fitBounds(bounds); } } function codeAddress() { var address = document.getElementById("address").value; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert("Geocode was not successful for the following reason: " + status); } }); } function infowindowhtml(id, section, name, address, distance, iconfile, placefile) { var html; if (section == 'cinema') { placefile = 'hall.aspx?id=' } else if (section == 'theatre') { placefile = 'theater.aspx?id=' } else if (section == 'music' || section == 'arts' || section == 'daylife') { placefile = 'place.aspx?pid=' } else if (section == 'umami') { placefile = 'market/shop/?id=' } else { placefile = 'place.aspx?id=' } html = '
' + address + '
' if (distance > 0) { html = html + 'Σε ' + distance + ' m
' } html = html +'' + html + '
' }); if(placecounter>1 && category==0){ var mimage = { url: '/tributes/numbers.png', // This marker is 20 pixels wide by 32 pixels tall. size: new google.maps.Size(32, 32), // The origin for this image is 0,0. origin: new google.maps.Point(32*(SpriteNum), 0), // The anchor for this image is the base of the flagpole at 0,32. anchor: new google.maps.Point(10, 10) }; } else{ var mimage = { url: '/tributes/numbers.png', // This marker is 20 pixels wide by 32 pixels tall. size: new google.maps.Size(32, 32), // The origin for this image is 0,0. origin: new google.maps.Point(0,32), // The anchor for this image is the base of the flagpole at 0,32. anchor: new google.maps.Point(10, 10) }; } var marker = new google.maps.Marker({ position: point, map: map, icon: mimage, title: '', zIndex:10*SpriteNum+1 }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); gmarkers.push(marker); // if(zoomlevel==15)//company map // { // infowindow.open(map,marker); // } } function locateAddress1() { document.getElementById("SimilarAddress1").style.display = 'block'; var address if (swapped==1){ address = document.getElementById("Address2"); }else{ address = document.getElementById("Address1"); } //alert(address.value); if (addressok != address.value){ geocoder.getLocations(address.value, add2candidates1); geocoder.getLocations(address.value +" οδός", add2candidates1); geocoder.getLocations(address.value + " λεωφόρος", add2candidates1); document.getElementById("SimilarAddress1").innerHTML = ""; setTimeout("displaysimilar1()", 500); }else{ gotodirections(addressok,endlat,endlon); } } function swapvalues() { var tmpaddress; var tmpcoords; var txtaddress1 = document.getElementById('Address1'); var txtaddress2 = document.getElementById('Address2'); tmpaddress = txtaddress1.value ; txtaddress1.value = txtaddress2.value; txtaddress2.value = tmpaddress; if (swapped==0){ swapped = 1; document.getElementById('Address1').disabled=true; document.getElementById('Address2').disabled=false; }else{ swapped = 0; document.getElementById('Address1').disabled=false; document.getElementById('Address2').disabled=true; }; } function add2candidates1(response) { place = response; document.getElementById("SimilarAddress1").innerHTML = ""; if (place.Status.code == "200") { for (var i = 0; i < place.Placemark.length; i++) { p1c.push("" + place.Placemark[i].address + ""); p1c.push(place.Placemark[i].address); p1c.push(place.Placemark[i].Point.coordinates[1]); p1c.push(place.Placemark[i].Point.coordinates[0]); // alert("mphke"); } } } function displaysimilar1() { var txtaddress1 = document.getElementById('Address1'); var divsimilar = document.getElementById('SimilarAddress1'); switch (p1c.length) { case 12: //txtaddress1.value = p1c[1]; divsimilar.style.visibility = "hidden"; endlat = p1c[2]; endlon = p1c[3]; gotodirections(p1c[1],p1c[2],p1c[3]); p1c = []; break; case 0: divsimilar.style.visibility = "visible"; divsimilar.innerHTML += "H Διεύθυνση δεν υπάρχει..."; p1c = []; break; default: for (x = 0; x < p1c.length; x=x+4) { divsimilar.innerHTML += p1c[x]; }; p1c = []; divsimilar.style.visibility = "visible"; } }