var c=window.console; var firstopen=1; var timerShowInfo=null; var map; var latlngbounds = new google.maps.LatLngBounds(); var markers=new Object; var routen=new Object; var gmarkers=[]; var grouten=[]; var showgroups=new Array(); var showitems=new Array(); var ortskern; var images=new Array(); var isize=new google.maps.Size(29, 38); var ipos=new google.maps.Point(0,0); var itouch=new google.maps.Point(16, 38); /* DATEN AUSLESEN */ function getData() { $.post("/incs/ajax/getLocationsForMap.ajax.php", { multiCMSkey: 'grosshoeflein.eu' }, function(data) { markers=$.parseJSON(data); ortskern=new google.maps.LatLng(markers['gemeinde'][0]['location'][0],markers['gemeinde'][0]['location'][1]); //if (c) console.log(markers); $.post("/incs/ajax/getRoutesForMap.ajax.php", { multiCMSkey: 'grosshoeflein.eu' }, function(data) { if (data!='empty') { routen=$.parseJSON(data); /*start=new google.maps.LatLng(markers['gemeinde'][0]['location'][0],markers['gemeinde'][0]['location'][1]);*/ //if (c) console.log(routen); } initialize(); }); }); } /* MARKER SETZEN */ images["default"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_locations.png',isize,ipos,itouch); images["empfehlung"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_empfehlung.png',isize,ipos,itouch); images["essen"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_essen.png',isize,ipos,itouch); images["heurigerclosed"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_heuriger_closed.png',isize,ipos,itouch); images["heurigeropen"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_heuriger_open.png',isize,ipos,itouch); images["kultur"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_kultur.png',isize,ipos,itouch); images["route_rad"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_route_rad.png',isize,ipos,itouch); images["route_wandern"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_route_wandern.png',isize,ipos,itouch); images["sightseeing"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_sightseeing.png',isize,ipos,itouch); images["sport_land"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_sport_land.png',isize,ipos,itouch); images["sport_wasser"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_sport_wasser.png',isize,ipos,itouch); images["unterkunft"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_unterkunft.png',isize,ipos,itouch); images["wirtschaft"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_wirtschaft.png',isize,ipos,itouch); images["vereine"] = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/marker_medium_vereine.png',isize,ipos,itouch); var shadow = new google.maps.MarkerImage('http://www.grosshoeflein.at/images/default/marker/medium/schatten.png',new google.maps.Size(42, 26),new google.maps.Point(3,0), new google.maps.Point(0,21)); var latlngToPoint = function(map,latlng,z) { var normalizedPoint = map.getProjection().fromLatLngToPoint(latlng); // returns x,y normalized to 0~255 var scale = Math.pow(2, z); var pixelCoordinate = new google.maps.Point(normalizedPoint.x * scale, normalizedPoint.y * scale); return pixelCoordinate; }; var pointToLatlng = function(map,point,z) { var scale = Math.pow(2, z); var normalizedPoint = new google.maps.Point(point.x / scale, point.y / scale); var latlng = map.getProjection().fromPointToLatLng(normalizedPoint); return latlng; }; /* einen bestimmten marker anzeigen */ function showMarker(which) { $.each(gmarkers, function(i,v) { if (v.id == which) v.setVisible(true); }); } /* marker einer kategorie anzeigen */ function showMarkers(showcat) { $.each(gmarkers, function(i,v) { if (v.cat == showcat) v.setVisible(true); }); //for (var i=0; i0) { clearAllMarkers(); $.each(showgroups, function(i,v) { if (c) console.log(v); showMarkers(v); $("#map-navi li input[type='checkbox']#ch"+v).attr('checked', true); }); } else { clearAllMarkers("no"); $("#map-navi li input[type='checkbox']").each(function() { if ($(this).is(':checked')) showMarkers($(this).attr("name")); }); } } /* alle definierten items anzeigen */ function showItems() { if (showitems.length>0) { clearAllMarkers(); $.each(showitems, function(i,v) { if (c) console.log(v); showMarker(v); }); } } /* karte zurücksetzen firstopen==0 >>> beim öffnen der flappe die karte initiieren firstopen==1 >>> beim erstmaligen öffnen der flappe die map initialisieren und positionieren firstopen==2 >>> komplettreset, alle kats zurücksetzen, navi zurücksetzen, zoom zurücksetzen firstopen==3 >>> komplettreset, alle kats zurücksetzen, navi zurücksetzen, zoom auf alles */ function refreshMap() { google.maps.event.trigger(map, 'resize'); showGroups(); showItems(); if (firstopen>=1) { map.setCenter(ortskern); if (map.getZoom() != 15) map.setZoom(15); if (typeof ortskern != 'undefined') { var pxlocation=latlngToPoint(map,ortskern,15); map.panTo(pointToLatlng(map,new google.maps.Point(pxlocation.x+200,pxlocation.y),15)); } if (firstopen>=2) resetMarkers(); if (firstopen>=3) map.fitBounds (latlngbounds); firstopen=0; } } /* marker erstellen und in die map einfügen links und infotexte verknüpfen */ function createMarker(data) { var marker = new google.maps.Marker({ map:map, title: data.mytitel, position: new google.maps.LatLng(data.location[0], data.location[1]), clickable: true, draggable: false, icon: images[data.marker], shadow: shadow, zIndex: data.zindex, cat: data.cat, url: (typeof data.url != 'undefined') ? data.url : null , id: data.moduleID }); var textinfo = "

"+data.mytitel+"

"; if (typeof data.infotext != 'undefined') textinfo=textinfo+"
"+data.infotext+"
"; // if (typeof data.url != 'undefined') textinfo=textinfo+"
"+data.url+"
"; //if (c) console.log(textinfo); google.maps.event.addListener(marker, "mouseover", function() { if (timerShowInfo) { clearTimeout(timerShowInfo); timerShowInfo=null; $("#map-item-info").html(textinfo); } else { $("#map-navi").hide(); $("#map-item-info").html(textinfo).show(); } }); google.maps.event.addListener(marker, "mouseout", function() { timerShowInfo = setTimeout(function() { $("#map-item-info").html(""); $("#map-navi").show(); $("#map-item-info").hide(); timerShowInfo=null; }, 1500); }); if (typeof data.url != 'undefined') { if (data.url.length>0) { google.maps.event.addListener(marker, "click", function() { location.href=data.url; }); } } var liitem=$("#map-navi ul#cat-navi li[rel='"+data.cat+"']"); if (liitem.css("display")!="block") liitem.show(); return marker; } /* route erstellen und in die map einfügen links und infotexte verknüpfen */ function createRoute(details) { var newCoords=[]; $(details.coords).each(function() { var point=new google.maps.LatLng(this[0], this[1]); newCoords.push(point); }); var newRoute = new google.maps.Polyline({ path: newCoords, strokeColor: details.color, strokeOpacity: 1.0, strokeWeight: 3, map: map }); //newRoute.setMap(map); var textinfo = "

"+details.mytitel+"

"; if (typeof details.infotext != 'undefined') textinfo=textinfo+"
"+details.infotext+"
"; google.maps.event.addListener(newRoute, "mouseover", function() { if (timerShowInfo) { clearTimeout(timerShowInfo); timerShowInfo=null; $("#map-item-info").html(textinfo); } else { $("#map-navi").hide(); $("#map-item-info").html(textinfo).show(); } }); google.maps.event.addListener(newRoute, "mouseout", function() { timerShowInfo = setTimeout(function() { $("#map-item-info").html(""); $("#map-navi").show(); $("#map-item-info").hide(); timerShowInfo=null; }, 1500); }); return newRoute; } /* karte initiieren */ function initialize() { map = new google.maps.Map(document.getElementById('map-wrapper'), { zoom: 15, center: ortskern, mapTypeId: google.maps.MapTypeId.HYBRID, streetViewControl: false }); /* maptypes HYBRID TERRAIN ROADMAP SATELLITE */ if (markers) { for (var cat in markers) { for (var i = 0; i < markers[cat].length; i++) { var details = markers[cat][i]; if ((details.location[0]>0) && (details.location[1]>0)) { latlngbounds.extend(new google.maps.LatLng(details.location[0], details.location[1])); gmarkers.push(createMarker(details)); } } } } if (routen) { for (var routeID in routen) { var details=routen[routeID]; latlngbounds.extend(new google.maps.LatLng(details.location[0], details.location[1])); gmarkers.push(createMarker(details)); grouten.push(createRoute(details)); } } clearAllMarkers("no"); } google.maps.event.addDomListener(window, 'load', getData); $(document).ready(function() { $("#map-navi ul#cat-navi input[type='checkbox']").click(function(e) { var stat=0; if ($(this).is(':checked')) { showMarkers($(this).attr("name")); stat=1; } else hideMarkers($(this).attr("name")); $.get("/incs/ajax/saveMapCatStatus.ajax.php", { which:$(this).attr("name"), stat:stat }); }); $("#map-navi li#mapreset").click(function() { firstopen=2; refreshMap(); }); $("#map-navi li#mapreset2").click(function() { firstopen=3; refreshMap(); }); });