var map = null;
function addLoadEvent(func) {
//alert('Registriere onload event');
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function showAddressinput(){
document.getElementById('addressInputContainer').style.display='block';
}
function hideAddressinput(){
document.getElementById('addressInputContainer').style.display='none';
}
function initMap(){
map = new VEMap('myMap');
//-> Zeige Konrad Logo und Icon
//var shape=new VEShape(VEShapeType.Pushpin, new VELatLong(47.06893, 15.44258));
//shape.SetCustomIcon('/grafiken/icon_orange.gif');
//map.AddShape(shape);
map.onLoadMap = function(){
document.getElementById('loadingIndicator').style.display='none';
};
map.LoadMap(new VELatLong(46.78926667, 13.9275), 1 ,'r' ,false);
//map.ClearInfoBoxStyles();
//map.SetInfoBoxStyles();
showPois();
}
function calculateAndDisplayRoute(){
if (document.getElementById('txtCity').value=='' || document.getElementById('txtState').value=='' ){
alert('Bitte geben Sie eine Adresse ein.');
return;
}
//document.getElementById('addressInput').style.display='none';
hideAddressinput();
document.getElementById('loadingIndicator').style.display='block';
//document.getElementById('resultMapContainer').style.display='block';
//map.Resize(775, 500);
var locations=new Array();
var target = document.getElementById('txtStreet').value;
if (target !='') target +=', ';
//target += document.getElementById('txtCity').value+', '+document.getElementById('txtState').value;
//locations.push(target);
//locations.push(new VELatLong(47.06893, 15.44258));
// var options=new VERouteOptions;
// options.DrawRoute = true;
options.RouteWeight = 10;
options.RouteZIndex = 3300;
options.SetBestMapView = true;
options.RouteCallback = CalculatingRouteCompleted;
options.DistanceUnit = VERouteDistanceUnit.Kilometer;
options.ShowDisambiguation = false;
options.ShowErrorMessages = false;
options.UseMWS = false;
try{
map.GetDirections(locations, options);
}catch(e){
alert(e.message);
}
}
function CalculatingRouteCompleted(route){
// //alert(route);
// alert(route.RouteLegs[0].Itinerary.Items.length);
// alert(route.RouteLegs[0].Itinerary.Items[0].LatLong.Latitude);
// result = document.getElementById('content');
// for (var i = 0; i < route.RouteLegs[0].Itinerary.Items.length; i++) {
// alert(route.RouteLegs[0].Itinerary.Items[i].Shape.GetPoints().length);
//
// //result.innerHTML = result.innerHTML + ' ' + route.RouteLegs[0].Itinerary.Items[i].LatLong.Latitude + ' ' + route.RouteLegs[0].Itinerary.Items[i].LatLong.Longitude + '
';
// }
// return;
//
if(route==null || route.Distance == 0){
//document.getElementById('loadingIndicator').style.display='none';
//document.getElementById('resultMapContainer').style.display='none';
//document.getElementById('addressInput').style.display='block';
//document.getElementById('resultMapContainer').style.display='none';
document.getElementById('loadingIndicator').style.display='none';
showAddressinput();
alert('Die Abfahrtsadresse konnte nicht gefunden werden.\r\n Bitte überprüfen Sie Ihre Eingabe.');
return;
}
document.getElementById('loadingIndicator').style.display='none';
var turns = "
Entfernung: " + route.Distance.toFixed(1) + "km"; var legs = route.RouteLegs; var leg = null; var turnNum = 0; //document.getElementById('loadingIndicator').style.display='none'; //document.getElementById('resultMapContainer').style.display='block'; //map.ShowAllShapeLayers(); //map.SetMapView(route.ShapePoints); /*var bounds=new Array(); bounds.push(route.ShapePoints[0]); bounds.push(route.ShapePoints[route.ShapePoints.length-1]);*/ //map.SetMapView(route.RouteLegs[0].Itinerary.Items); // result = document.getElementById('content'); // result.innerHTML = 'LaLa: ' + route; // ///////////////// // var legs = route.RouteLegs; // var turns = "Total distance: " + route.Distance.toFixed(1) + " mi\n"; // var numTurns = 0; var leg = null; // Get intermediate legs // for(var i = 0; i < legs.length; i++){ // // Get this leg so we don't have to derefernce multiple times // leg = legs[i]; // // Leg is a VERouteLeg object // // Unroll each intermediate leg // var turn = null; // // The itinerary leg // for(var j = 0; j < leg.Itinerary.Items.length; j ++){ // turn = leg.Itinerary.Items[j]; // // turn is a VERouteItineraryItem object // numTurns++; // turns += numTurns + ".\t" + turn.Text + " (" + turn.Distance.toFixed(1) + " mi)\n"; // } // } // alert(turns); } function SetDirections(s) { var d = document.getElementById("directions"); d.innerHTML = s; d.style.display='block'; } function handleKeyUp(evt) { evt = (evt) ? evt : ((window.event) ? event : null); if (evt) { if (evt.keyCode=='13'){ calculateAndDisplayRoute(); } } } function backToAddressInput(){ document.getElementById('loadingIndicator').style.display='none'; document.getElementById('resultMapContainer').style.display='none'; document.getElementById('addressInput').style.display='block'; }