var map;var markers = [];var countries = {};var mids = [];var infowindow;var autoHeight;function initialize() { var mapOptions = { backgroundColor:'#FBFBFB', zoom:3, center: new google.maps.LatLng(13,10), panControl: false, mapTypeControl: false, streetViewControl: false, zoomControl: true, zoomControlOptions: {position: google.maps.ControlPosition.LEFT_CENTER}, scrollwheel: false, mapTypeId: google.maps.MapTypeId.ROADMAP, minZoom:3, maxZoom:10, styles:[{featureType: 'water', stylers:[{visibility:'simplified'}, {color:'#FBFBFB'}]},{featureType: 'road', stylers:[{visibility:'simplified'}]},{featureType: 'road', elementType:'labels', stylers:[{visibility:'simplified'}]},{featureType: 'landscape.natural', stylers:[{visibility:'simplified'},{color:'#D6CFCF'}]},{featureType: 'landscape.man_made', elementType:'geometry.fill', stylers:[{color:'#a4afaa'}, {lightness:25}]},{featureType: 'administrative', elementType:'labels.text.fill', stylers:[{color:'#4F4F4F'}]},{featureType: 'administrative.province', stylers:[{visibility:'simplified'}]},{featureType: 'poi', stylers:[{visibility:'off'}]},{featureType: 'road', elementType:'labels', stylers:[{visibility:'off'}]},{featureType: 'road', stylers:[{color:'#5A6F67'}, {lightness:80}]},{featureType: 'road.arterial', stylers:[{visibility:'off'}]},{featureType: 'road.local', stylers:[{visibility:'off'}]},{featureType: 'transit', stylers:[{visibility:'simplified'}]}] }; map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions); window.setTimeout(initMap, 0);}function initMap() { $('#map-wrapper').prepend('
Daten werden geladen
'); $.ajax({ url: "/gmaps/static_fusionTable", dataType: "json", success:function(data) { drawPolygon(data); countryCode = $("#map_canvas").attr("class"); if(countryCode!='' && countryCode!='ALL'){ google.maps.event.trigger(countries[countryCode], 'click' ); } } });}function drawPolygon(data) { var rows = data['rows']; for (var i in rows) { var newCoordinates = []; var countryArea = {'w':180.0, 'e':-180.0, 's':90.0, 'n':-90.0}; var geometries = rows[i][1]['geometries']; var admin3 = rows[i][2]; if (geometries) { for (var j in geometries) { x = constructNewCoordinates(admin3,geometries[j],countryArea); newCoordinates.push(x[0]); countryArea = x[1]; } } else { x = constructNewCoordinates(admin3,rows[i][1]['geometry'],countryArea); newCoordinates.push(x[0]); countryArea = x[1]; } country = new google.maps.Polygon({ paths: newCoordinates, strokeColor: "#BA010B", strokeOpacity: 0.2, strokeWeight: 1, fillColor: "#BA010B", fillOpacity: 0.1, countryArea:countryArea, name:admin3 }); country.setMap(map); showCountryInfo(country, admin3); google.maps.event.addListener(country, 'mouseover', function() { this.setOptions({fillOpacity: 0.3}); }); google.maps.event.addListener(country, 'mouseout', function() { this.setOptions({fillOpacity: 0.1}); }); } $('#map_country').on('click','li',function(){ $('.iWrap li').removeClass('active'); $(this).addClass('active'); $.ajax({ url: "/gmaps/getProjectInfo", data: {country:$(this).parent().attr('id'),project:$(this).attr('id'),lang:"eng"}, dataType: "json", cache: false, beforeSend: function(){ $('#map_project').animate({right:'-30%'}, 200, function() { $('#map_project .iWrap').scrollTop(0); }); }, success:function(data) { window.history.pushState(null, data.title, data.url); $('#map_project .iWrap').html(data.html); $('#map_project').delay(20).animate({right:'5%'}, 200, function() { if ($('#map_project .projDesc').height() > 300 && $('#map_project .mapIndex').length){ autoHeight = $('#map_project .projDesc').height(); $('#map_project .projDesc').animate({height:'300px', paddingBottom:'31px'}, 100).addClass('hide').attr('style',''); $('#map_project .readMore').fadeIn(); } $('#map_project').attr('class','').addClass('active').attr('style',''); }); $('#map_country').addClass('hiding').removeClass('active'); $('#map_article').attr('class',''); $('#map_country .activity').fadeOut(); $('#map_project .activity').fadeIn(); $('#map_article .activity').fadeOut(); } }); }); $('#map_project').on('click','li',function(){ $('#map_project li').removeClass('active'); $(this).addClass('active'); $.ajax({ url: "/gmaps/getArticleInfo", data: {arturl:$(this).attr('data-value'),lang:"eng"}, dataType: "json", cache: false, beforeSend: function(){ $('#map_article').animate({right:'-25%'}, 200, function() { $('#map_article').attr('class','').addClass('changing').attr('style',''); $('#map_article .iWrap').scrollTop(0); }); }, success:function(data) { $('#map_article .iWrap').html(data.html); $('#map_article').delay(20).animate({right:'12%'}, 200, function() { $('#map_article').attr('class','').addClass('active').attr('style',''); $('.mapIndex a').click(function(){return false;}); }); $('#map_project').addClass('hiding').removeClass('active'); $('#map_project .activity').fadeOut(); $('#map_article .activity').fadeIn(); } }); }); $('#map_country').on('click','.close, .activity', function(){ moveInfo($(this).parent()); }); $('#map_project').on('click','.close, .activity',function(){ $('#map_project').attr('class',''); $('#map_article').attr('class',''); $('#map_country').addClass('active').removeClass('hiding'); $('#map_country .activity').fadeIn(); $('#map_project .activity').fadeOut(); $('#map_article .activity').fadeOut(); $('.iWrap li').removeClass('active'); }); $('#map_article').on('click','.close, .activity',function(){ $('#map_article').attr('class',''); $('#map_project').addClass('active').removeClass('hiding'); $('#map_project .activity').fadeIn(); $('#map_article .activity').fadeOut(); $('#map_project li').removeClass('active'); }); $('#map_project').on('click','.readMore',function(){ $('#map_project .readMore').slideUp(100, function(){ $('#map_project .projDesc').animate({height: autoHeight}, 100).removeClass('hide').attr('style',''); }); }); $('.mapBlocker').fadeOut().remove(); if (isTouchDevice()) {} else { $("#map_country, #map_project, #map_article").on('mouseenter',function() { $(this).addClass("hover"); }).on('mouseleave',function() { $(this).removeClass("hover"); }); }}function showCountryInfo(poly, admin3) { countries[admin3] = poly; countryCode = $("#map_canvas").attr("class"); google.maps.event.addListener(poly,'click', function(event) { var mapCWidth = $('#map_country').width(); $('#map_country').animate({right:'-'+mapCWidth}, 100); $('#map_country .iWrap').fadeOut(); $('#map-wrapper').prepend('
Daten werden geladen
'); this.setOptions({fillOpacity: 0.3}); $.ajax({ url: "/gmaps/getCountryInfo", data: {country:admin3,lang:"eng"}, dataType: "json", cache: false, success:function(data) { if(countryCode){ window.history.pushState(null, data.title, data.url); $("title").text(data.title); for (i in markers) { markers[i].setMap(null); } markers.length = 0; $('#map_country .iWrap').html('

'+data.title+'

'); var info = []; info.push('
'); $('#map_country .iWrap').append(info.join('')); $('#map_country').delay(100).css('right','0%'); $('#map_country').attr('class','').addClass('active').attr('style',''); $('#map_country .iWrap').delay(150).fadeIn(); $('#map_project').removeClass('active'); $('#map_article').removeClass('active'); $('#map_country .activity').fadeIn(); $('#map_project .activity').fadeOut(); $('#map_article .activity').fadeOut(); showArrays(poly,event); }else{ window.location.href = data.url; } }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.statusText); alert(thrownError); } }); $('.mapBlocker').fadeOut().remove(); }); }function moveInfo(e) { if ($(e).is('.active')) { $(e).removeClass('active'); } else { $(e).addClass('active'); }}function constructNewCoordinates(admin3, polygon,countryArea) { var newCoordinates = []; var coordinates = polygon['coordinates'][0]; for (var i in coordinates) { lng = coordinates[i][0]; lat = coordinates[i][1]; if (parseFloat(lng) <= countryArea['w']) { countryArea['w'] = lng } if (parseFloat(lng) >= countryArea['e']) { countryArea['e'] = lng } if (parseFloat(lat) >= countryArea['n']) { countryArea['n'] = lat } if (parseFloat(lat) <= countryArea['s']) { countryArea['s'] = lat } newCoordinates.push(new google.maps.LatLng(lat,lng)); } return [newCoordinates,countryArea];}function setMarkers(title, text, lat, lng, type) { var myLatLng = new google.maps.LatLng(lat,lng); var marker = new google.maps.Marker({ position:myLatLng, map:map, icon:'/common/marker'+type+'.png', animation:google.maps.Animation.DROP }); markers.push(marker);}function showArrays(poly,event) { console.log(poly.name, poly.countryArea); countryArea = poly.countryArea; var southWest = new google.maps.LatLng(countryArea['s'],countryArea['w']); var northEast = new google.maps.LatLng(countryArea['n'],countryArea['e']); var bounds = new google.maps.LatLngBounds(southWest,northEast); map.fitBounds(bounds);}google.maps.event.addDomListener(window, 'load', initialize);