/** * Checks the browser version an type */ var agt=navigator.userAgent.toLowerCase(); ie = (agt.indexOf("msie") != -1); ns = (navigator.appName.indexOf("Netscape") != -1); var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1)); var mac = (agt.indexOf("mac")!=-1); var gmarkers = []; var html = []; /** * Events that resizes the map division if the browser window * is resized by the user */ if (window.attachEvent) window.attachEvent("onresize", resizeMapDiv); else window.addEventListener("resize", resizeMapDiv, false); /** * Resizes the map division * @return void */ function resizeMapDiv() { function e(id) { return document.getElementById(id); } var offset = 0; for (var elem = e("map"); elem != null; elem = elem.offsetParent) { offset += elem.offsetTop; } var windowHeight = getWindowHeight(); var windowWidth = getWindowWidth(); var width = 700; if (ie) var height = windowHeight - offset - 18; else var height = windowHeight - offset - 18; if (height >= 0) { //e("map").style.height = height + "px"; //e("listcontainer").style.height = height + "px"; } if (width >= 0) { //e("map").style.width = width + "px"; //e("listcontainer").style.width = width + "px"; } } /** * Gets the height of the active window * @return int - height of the window */ function getWindowHeight() { if (window.self && self.innerHeight) { return self.innerHeight; } if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientHeight; } return 0; } /** * Gets the width of the active window * @return int - width of the window */ function getWindowWidth() { if (window.self && self.innerWidth) { return self.innerWidth; } if (document.documentElement && document.documentElement.clientWidth) { return document.documentElement.clientWidth; } return 0; } /** * Debug function for promt some data on the screen * @param string - string which should be prompted * @return void */ function debug(str) { if ((str) && (document.getElementById("debug"))) document.getElementById("debug").value = document.getElementById("debug").value + "-" + str + "-\n"; } /** * Hides the loading division * @return void */ function loaded() { if (document.getElementById("loading") != null) { document.getElementById("loading").style.display = "none"; document.getElementById("disable").style.display = "none"; } else { document.getElementById("loadingsmall").style.display = "none"; } } /** * Shows the loading division * @return void */ function loading() { if (document.getElementById("loading") != null) { document.getElementById("loading").style.display = "inline"; document.getElementById("disable").style.height = (getWindowHeight()-60) + "px"; document.getElementById("disable").style.display = "inline"; } else { document.getElementById("loadingsmall").style.display = "inline"; } } /** * Unchecks all checkbox-fields of the page * @return void */ function uncheckAll() { var ins = document.getElementsByTagName('input'); for (var i=0; iKeine Gemeinden gefunden!"; document.getElementById("resultlistcontainer").style.display = "none"; document.getElementById("registercontainer").style.display = "block"; loaded(); } else { //needed for fitting the map zoom level to the data var bounds = new GLatLngBounds(); map.clearOverlays(); var lines = new Array(); lines = returnValue.split("{|}"); if (lines.length > 100) document.getElementById("message").innerHTML = "über 100 Gemeinde(n) gefunden!
» Bitte verfeinern Sie die Suche!"; else document.getElementById("message").innerHTML = "" + (lines.length-1) + " Gemeinde(n) gefunden!"; document.getElementById("resultlist").innerHTML = ""; for(i=0;i<(lines.length-1);i++) { data = lines[i].split("|"); if (document.getElementById("id").value != "") { document.getElementById("keyword").value = data[1]; } point = new GLatLng(data[2], data[3]); marker = createMarker(point,data[1],data[4]); if (map.addOverlay(marker)) results.push(marker) gmarkers[i] = marker; html[i] = data[4]; document.getElementById("resultlist").innerHTML = document.getElementById("resultlist").innerHTML + "
  • " + data[1] + "
  • \n"; //Each time a point is found, extent the bounds ato include it ===== bounds.extend(point); } document.getElementById("resultlist").innerHTML = ""; //fits the map to the data map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); document.getElementById("resultlistcontainer").style.display = "block"; document.getElementById("registercontainer").style.display = "none"; loaded(); } } } } /** * Gets the search results and shows them in the map * @param request - http object * @return void */ function showSearchResults() { debug(request.readyState); } /** * Converts decimal to radian * @param float - decimal value * @return float - radian value */ function convertToRadian(deg) { return deg / (180/Math.PI); } /** * Fetches the distance of two point in kilometers * @param object - GLatLng object of point1 * @param object - GLatLng object of point2 * @return float - kilometers */ function getKilometers(point1, point2) { km = getDistanceGeneric(6378.8, point1, point2); return km; } /** * Calculates the distance between two point * @param float - muliplicator for measure-type (e.g. km or miles) * @param object - GLatLng object of point1 * @param object - GLatLng object of point2 * @return float - kilometers */ function getDistanceGeneric(mult, point1, point2) { point1.xR = convertToRadian(point1.y); point1.yR = convertToRadian(point1.x); point2.xR = convertToRadian(point2.y); point2.yR = convertToRadian(point2.x); return mult * (Math.acos(Math.sin(point1.xR) * Math.sin(point2.xR) + Math.cos(point1.xR) * Math.cos(point2.xR) * Math.cos(point2.yR - point1.yR))); } /** * Function that creates the markers in the map * @param point - pointer object with the coordinates * @param name - title of the marker * @param html - description for the use in the infobubble * @return marker - object */ function createMarker(point,name,html) { var icon = new GIcon(); icon.image = "img/icon/marker.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(20, 34); icon.shadowSize = new GSize(35, 35); icon.iconAnchor = new GPoint(6, 20); var marker = new GMarker(point, icon); marker.tooltip = '
    '+name+'<\/nobr><\/div>'; GEvent.addListener(marker, "click", function() { //map.openInfoWindowHtml(point, html); map.openInfoWindowHtml(point, html); }); GEvent.addListener(marker,"mouseover", function() { showTooltip(marker); }); GEvent.addListener(marker,"mouseout", function() { tooltip.style.visibility="hidden" }); return marker; } function showTooltip(marker) { tooltip.innerHTML = marker.tooltip; var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom()); var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom()); var anchor=marker.getIcon().iconAnchor; var width=marker.getIcon().iconSize.width; var height=tooltip.clientHeight; var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + width, offset.y - point.y -anchor.y -height)); pos.apply(tooltip); tooltip.style.visibility="visible"; } function setDraggableMarker (lat,lon) { var point = new GLatLng(lat, lon); map.setZoom(17); map.setCenter(point); var icon = new GIcon(); icon.image = "img/icon/marker_big.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(50, 91); icon.shadowSize = new GSize(91, 91); icon.iconAnchor = new GPoint(23, 89); var marker = new GMarker(point, {icon:icon, draggable: true}); GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); }); GEvent.addListener(marker, "dragend", function() { var latlon = marker.getLatLng().toString().split(","); document.getElementById("gem_laengengrad").value = latlon[1].substr(0,latlon[1].length-1); document.getElementById("gem_breitengrad").value = latlon[0].substr(1,latlon[1].length-1); //Todo: Fehler prüfen und wieder integrieren //marker.openInfoWindowHtml("Bitte speichern Sie
    die neue Positionierung ab."); }); map.addOverlay(marker); } function clearId() { document.getElementById("id").value=""; }