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.searchAndAddMarker = function (search_string, html) { if (this.geo == null) { this.geo = new google.maps.Geocoder(); } //console.log(search_string) 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, lat, lon) { if (this.geo == null) { this.geo = new google.maps.Geocoder(); } var customLatLng = "" this._place = place; if((lat!="null") && (lon!="null")){ customLatLng = {lat: parseFloat(lat), lng: parseFloat(lon)}; } // ====== 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(); //console.log("results", results) p[0] = results[0].geometry.location.lng(); p[1] = results[0].geometry.location.lat(); if(customLatLng){ latLng = customLatLng; console.log('custom', latLng) } else { latLng = results[0].geometry.location; console.log('google', latLng) } var options = { zoom: 17, center: latLng, 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: latLng, 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; } 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); } } ); }