var map = null;
var layer_icons = null;
var icon = "/schnipsel/id/bingmaps/img/pin_blau.png";
var xmlData = "http://www.br-online.de/schnipsel/id/1201526516235/bing/data/Ortsliste_Radltour.zzz";
var map_start_latlon = new VELatLong(48.562861797629836, 11.540841101625006);
var map_start_zoom = 7;

window.onload = function()
{
	GetMap();
}


function GetMap() {
    map = new VEMap('myMap');
    map.SetDashboardSize(VEDashboardSize.Small);
	map.LoadMap(map_start_latlon, map_start_zoom ,VEMapStyle.Road ,false);
	
	layer_icons = new VEShapeLayer();
    map.AddShapeLayer(layer_icons);
	
	
	map.DeleteAllShapes();
	LoadKML(xmlData,layer_icons);
	
	map.ClearInfoBoxStyles();
	
	map.EnableShapeDisplayThreshold(false);

    //var co = new VEClusteringOptions();
    //co.Callback = ClusteringCallback;
    //layer_icons.SetClusteringConfiguration(VEClusteringType.Grid, co);
		
}

function LoadKML(file, layer) {
    var veLayerSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, file, layer);
    map.ImportShapeLayerData(veLayerSpec, loadXMLData, false);
}

function loadXMLData(feed) {

    var shape_count = feed.GetShapeCount();
    var shape;
	
    for (var i = 0; i < shape_count; ++i) {

        shape = feed.GetShapeByIndex(i);
		shape.ImageOffset = new VEPixel(-53, -13);
		shape.SetCustomIcon("<img class='' src='"+ icon + "' />");
		var linkUrl = "<div class=\"infobox_titel\">" + shape.GetTitle() + "</div>";
		linkUrl += "<a href=\"" + shape.GetMoreInfoURL() + "\" target=\"_blank\"><img src=\"" + shape.GetPhotoURL() + "\" style=\"border:none;\"/></a>";
		linkUrl += "<br style=\"clear:both;\"><a class=\"infobox_link\" href=\"" + shape.GetMoreInfoURL() + "\" target=\"_blank\"><img src=\"http://www.br-online.de/image/icon/list-pfeil.gif\" class=\"infobox_multimedia\" /><b>BR-Radltour 2010:</b> Stadtansichten " + shape.GetTitle() + "</a>";
		
		

		var d = shape.GetDescription();
         d = "<div style='width:170px; margin:0px 0px 0px 0px; text-align:left;'>" +linkUrl + "</div>";
		 		shape.SetTitle("");
				shape.SetPhotoURL("");
                shape.SetMoreInfoURL("");
				shape.SetDescription(d);
           
        

    }
}

