var map;
var temp;
var panto=false;
var geocoder;
var markers = Array();
var infowindow;
var panSpecial=false;
var picid;
function initialize() {
geocoder = new google.maps.Geocoder();
infowindow = new google.maps.InfoWindow();
setTimeout(animateSearchInfo, 4000);
/*
map = new google.maps.Map(document.getElementById("map_div"), {
zoom: startzoom,
center: new google.maps.LatLng(startlat, startlng),
mapTypeId: google.maps.MapTypeId.SATELLITE
});
*/
var mapOptions = {
center: new google.maps.LatLng(startlat, startlng),
zoom: startzoom,
mapTypeId: "OSM",
mapTypeControlOptions: {
mapTypeIds: [
"OSM",
google.maps.MapTypeId.HYBRID,
],
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
}
};
map = new google.maps.Map(document.getElementById('map_div'), mapOptions);
map.mapTypes.set("OSM", new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256, 256),
name: "Karte",
maxZoom: 18
}));
google.maps.event.addListener(infowindow, "closeclick", function() {
this.anchor.setIcon('pins/red.png');
delete this.anchor;
delete this.anchorId;
pulldown();
});
/* Unbedingt ersetzen, wenn Google die Möglichkeit bietet */
google.maps.event.addListener(map, "zoom_changed", function() {
if(map.getZoom()<4) {
map.setZoom(4);
}
});
google.maps.event.addListener(map, "idle", function() {
map.lastCenter = map.getCenter();
map.lastZoom = map.getZoom();
if(panSpecial) {
if(!dl_marker(picid)) {
map.panTo(map.lastCenter);
rmk();
}
panSpecial=false;
openInfoBox(picid);
} else {
if(!dl_marker(picid)) {
map.panTo(map.lastCenter);
rmk();
}
}
if(typeof(panToOpenInfoBox) == 'function') {
panToOpenInfoBox();
delete panToOpenInfoBox;
}
});
diashowAppend();
$('#diashow').cycle({
pause: 1
});
}
function animateSearchInfo() {
$('#searchinfo').animate({scrollTop: document.getElementById('searchinfo').scrollHeight}, document.getElementById('searchinfo').scrollHeight*75, 'linear', function() {
setTimeout(function() {
$('#searchinfo').scrollTop(0);
setTimeout(animateSearchInfo, 3000);
}, 200);
});
}
function contact(id) {
lytelink = document.createElement('a');
lytelink.setAttribute('href', 'kontakt.php?id='+id);
lytelink.setAttribute('rel', 'lyteframe');
lytelink.setAttribute('rev', 'width: 630px; height: 380px;');
myLytebox.start(lytelink, false, true);
}
function dl_marker(id) {
url = "marker.php?minlat="+map.getBounds().getSouthWest().lat()+"&minlng="+map.getBounds().getSouthWest().lng()+"&maxlat="+map.getBounds().getNorthEast().lat()+"&maxlng="+map.getBounds().getNorthEast().lng()+"&zoom="+map.getZoom();
if(typeof(id) == 'number') {
url += "&prio="+id;
}
var check=false;
$.ajax({
type: "GET",
url: url,
dataType: "script",
success: function() {rmk();check=true;},
async: false
});
return check;
}
function rmk() {
oldmarkers = markers;
markers = Array();
createmarkerd();
}
function createmarkerd() {
if(typeof createmarker == "function") {
createmarker();
$(oldmarkers).each(function(index, value) {
if(value != null && typeof(value) != "undefined") {
if(value == infowindow.anchor) {
infowindow.close();
infowindow.anchor.setIcon('pins/'+infowindow.anchor.color+'.png');
delete infowindow.anchor;
delete infowindow.anchorId;
}
value.setMap(null);
}
});
}
else {
setTimeout(createmarkerd,1);
}
}
function init_marker(id, lat, lng) {
if(typeof(oldmarkers[id]) != "undefined") {
markers[id] = oldmarkers[id];
oldmarkers[id] = null;
} else {
var marker = new google.maps.Marker({draggable: false, map: map, position: new google.maps.LatLng(lat, lng)});
google.maps.event.addListener(marker, "mouseover", function() {
if(typeof(timeout) != 'undefined'){clearTimeout(timeout);}
if(infowindow.anchor != this) {
timeout = setTimeout(function(){openInfoBox(id);},500);
}
});
google.maps.event.addListener(marker, "mouseout", function() {
if(typeof(timeout) != 'undefined'){clearTimeout(timeout);}
});
if(picid == id) {
infowindow.anchorId = id;
infowindow.anchor = marker;
marker.setIcon('pins/green.png');
marker.setZIndex(2);
} else {
marker.setIcon('pins/red.png');
marker.setZIndex(1);
}
markers[id] = marker;
}
}
function search(address) {
geocoder.geocode({
'address': address,
'bounds': map.getBounds()
}, function(result, status) {
if(status == google.maps.GeocoderStatus.OK) {
document.getElementById("searchinfo").innerHTML = "";
map.fitBounds(result[0].geometry.bounds);
} else {
document.getElementById("searchinfo").style.color = "#A00";
document.getElementById("searchinfo").innerHTML = "Entschuldigung!
Für Ihre Suche wurde leider kein Ergebnis gefunden.";
}
});
}
function pulldown() {
$("#pulldown").slideUp("slow", function() {
$("#bogen").slideDown("slow", function() {
$("#pullup").slideDown("slow");
});
});
}
function pullup() {
$("#pullup").slideUp("slow", function() {
$("#bogen").slideUp("slow", function() {
$("#pulldown").slideDown("slow");
});
});
}
function panTo(id, lat, lng) {
picid=id;
panToOpenInfoBox = function(){openInfoBox(id);};
map.panTo(new google.maps.LatLng(lat,lng));
}
function openInfoBox(id) {
if(typeof(markers[id]) != "undefined") {
pullup();
var marker = markers[id];
$.ajax({
type: "GET",
url: "bubble.php?id="+id,
dataType: "html",
success: function(data) {bild=new Image();bild.onload=function() {
//infowindow.setOptions({maxWidth: bild.width});
infowindow.setContent(data);
if(typeof(infowindow.anchor) != "undefined" && infowindow.anchor != null) {
infowindow.anchor.setIcon('pins/red.png');
infowindow.anchor.setZIndex(1);
}
marker.setIcon('pins/green.png');
marker.setZIndex(2);
infowindow.anchor=marker;
infowindow.anchorId=id;
picid=id;
infowindow.open(map,marker);
addthis_config = {"data_track_addressbar":true};
addthis_share = {"url":"http://www.LuftbildWeserEms.de/"+picid,"title":"LuftbildWeserEms.de | Bild "+picid};
addthis.toolbox('.addthis_toolbox', addthis_config, addthis_share);
};
bild.src=data.replace(/^[\S\s]*?background="(.*?)"[\S\s]*?$/,'$1');
},
error: function(request) {marker.openInfoWindowHtml("Entschuldigung!
Es ist ein Fehler aufgetreten!
Fehlercode: "+request.status+"
Bitte benachrichtigen Sie uns, sollte dieser Fehler wiederholt auftreten.");}
});
}
else {
setTimeout(function(){openInfoBox(id);},1);
}
}