var LEO_GOOGLE_MAP = new function() { this.geo; this.map; this.gdir; this.geocoder; this.addressMarker; this.trafficInfo; this.first_try = true; this.red_marker; this.minLat; this.minLng; this.maxLat; this.maxLng; this._event; this.document; this.setEvent = function (document, event) { this.document = document; this._event = event; } this.setMarker = function (data) { try { var event = data.event; var teaserTextAttribute = "Online-Text"; var pictureAttribute = "Online-Bild"; for (i = 0; i < data.statusinfo.count; i++) { var lat = event[i].date[0].venue.venue_lat; var lon = event[i].date[0].venue.venue_lon; lat = lat + (Math.random() * 0.001); lon = lon + (Math.random() * 0.001); this.minLat = Math.min(minLat, lat - 0.01); this.minLng = Math.min(minLng, lon - 0.01); this.maxLat = Math.max(maxLat, lat + 0.01); this.maxLng = Math.max(maxLng, lon + 0.01); var id = event[i].event_id; var title = event[i].event_identifier; if (title == _event) { continue; } var staette = event[i].date[0].venue_allocation; var city = event[i].date[0].venue.venue_town; var postcode = event[i].date[0].venue.venue_postcode; var street = event[i].date[0].venue.venue_street; var house_nr = event[i].date[0].venue.venue_house_number; if (street != null) { if (house_nr != null) { street += " " + house_nr; } } else { street = ""; } var text = event[i].event_description; if (text == null) { if (event[i].textsystem != null && event[i].textsystem[teaserTextAttribute] != null) { text = event[i].textsystem[teaserTextAttribute].txt_content; } } if (text == null) { text = ""; } text.replace("
", ""); text = text.substring(0, 150) + '...'; street = street.substring(0, 28); staette = staette.substring(0, 28); title = title.substring(0, 40); var start = event[i].date[0].date_start; if (start.indexOf(" 00:00") != -1) { start = start.replace(" 00:00", ""); } else { start += ' Uhr'; } var ende = event[i].date[0].date_end; if (ende == null) { ende = event[i].date[0].date_start; } if (ende.indexOf(" 23:59") != -1) { ende = ende.replace(" 23:59", ""); } else { ende += ' Uhr'; } if (start == ende) { start += '
'; ende = ""; } else { start += ' -
'; } var bild = 'http://sport.azol.de:8082/leoonline/portals/aa/img/icons/veranstaltung.gif'; if (event[i].attributes != null && event[i].attributes[pictureAttribute] != null) { bild = event[i].attributes[pictureAttribute]; bild = bild.replace("width", "_w"); bild = bild.replace("height", "_h"); bild += '&width=120&height=-1'; } var html = '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '

' + title + '

'; html += '

' + text + 'mehr

'; html += '
WannWo
' + start + ende + '' + staette + '
' + street + '
'; html += '
'; this.addMarker(lat, lon, html); } } catch (e) { } } this.searchAndAddMarker = function (search_string, html) { if (this.geo == null) { this.geo = new google.maps.Geocoder(); } this.geo.geocode( { 'address': search_string}, function(results, status) { // If that was successful if (status == google.maps.GeocoderStatus.OK) { var p = new Array(); p[0] = results[0].geometry.location.lng(); p[1] = results[0].geometry.location.lat(); this.addMarker(p[1], p[0], html); } }); } this.showAddress = function (place, city, postcode, street, house_nr) { if (this.geo == null) { this.geo = new google.maps.Geocoder(); } this._place = place; // ====== Perform the Geocoding ====== this.geo.geocode( { 'address': city + ' ' + postcode + ' ' + street + ' ' + house_nr}, function(results, status) { // If that was successful if (status == google.maps.GeocoderStatus.OK) { var p = new Array(); p[0] = results[0].geometry.location.lng(); p[1] = results[0].geometry.location.lat(); var options = { zoom: 11, center: results[0].geometry.location, mapTypeId: google.maps.MapTypeId.ROADMAP } this.map = new google.maps.Map(this.document.getElementById("leo_google_map"), options); // Traffic-Infos var trafficLayer = new google.maps.TrafficLayer(); trafficLayer.setMap(map); var point = new google.maps.Point(p[0], p[1]); this.red_marker = new google.maps.Marker({ position: results[0].geometry.location, animation: google.maps.Animation.DROP, clickable: false }); this.red_marker.setMap(this.map); this.minLat = p[1] - 0.01; this.minLng = p[0] - 0.01; this.maxLat = p[1] + 0.01; this.maxLng = p[0] + 0.01; // Collecting Geodata country = results[0].address_components[7].short_name; if (results[0].address_components != null) { if (results[0].address_components[8] != null) { postcode = results[0].address_components[8].short_name; } if (results[0].address_components[4] != null) { city = results[0].address_components[4].long_name; } } var service = "http://sport.azol.de:8082/leoonline/JSONClientServlet?request=demo_geodata_collecting"; var args = "&z1=" + postcode + "&z2=" + city + "&z3=" + country + "&z4=" + place + "&z5=" + street + "&z6=" + house_nr + "&z7=" + p[0] + "&z8=" + p[1]; jQuery.get(service + args); service = "http://sport.azol.de:8082/leoonline/JSONClientServlet?request=evt_poi_search"; args = "&z1=" + escape(p[0] + " " + p[1]) + "&z2=5" + "&z3=max_rows:100&z4=filter:date_in_format:dd.MM.yyyy HH:mm"; jQuery.getJSON(service + args, setMarker); } else { if (first_try) { first_try = false; this.showAddress('', city, postcode, '', ''); return; } var container = document.getElementById("evt_details"); var google_div = document.getElementById("leo_google_map"); container.removeChild(google_div); } } ); } this.addMarker = function (lat, lon, html) { var point = new google.maps.LatLng(lat, lon); var icon = "http://maps.google.com/mapfiles/marker_green.png"; var shadow = new google.maps.MarkerImage('http://maps.gstatic.com/mapfiles/shadow50.png', new google.maps.Size(53, 32), new google.maps.Point(0,0), new google.maps.Point(12, 32)); var marker = new google.maps.Marker({ position: point, animation: google.maps.Animation.DROP, icon: icon, shadow: shadow, map: this.map }); var infoWindow = new google.maps.InfoWindow(); infoWindow.setPosition(point); infoWindow.setContent(html); google.maps.event.addListener(marker, 'click', function () { infoWindow.open(this.map); }); } }