﻿ 
 var map = null;
 var initLoc = new VELatLong(51.0860,2.6151,0);
 var UrsaMinor = new VELatLong(51.104142,2.609661,0);
 var plopsaLand = new VELatLong(51.0803,2.6032,0);
 var delvauxMuseum = new VELatLong(51.1054,2.6132,0);
 var pinPoint = null;
 var pinPixel = null;
                  
function GetMap() {
    map = new VEMap('myMap');
	map.LoadMap(initLoc, 12, VEMapStyle.Shaded, false, VEMapMode.Mode2D, true, 1);
	map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
    map.AttachEvent("onresize", MapResize);
    map.AttachEvent("onchangemapstyle", StyleChangeHandler);
    map.ShowMiniMap(0,0,VEMiniMapSize.Small);
    
    
    RealignMiniMap();
    AddPin();
}

function MapResize(e) {
    RealignMiniMap();
}

function RealignMiniMap() {
    var minimap = document.getElementById("MSVE_minimap");
    var xoffset = (GetMapWidth() - minimap.offsetWidth);
    map.ShowMiniMap(xoffset, 0, VEMiniMapSize.Small);
    document.getElementById("MSVE_minimap_resize").style.display = "none";
}

function GetMapWidth() {   
    return document.getElementById("myMap").offsetWidth;
}

function GetMapHeight() {
    return document.getElementById("myMap").offsetHeight;
}

function StyleChangeHandler(e) {
    if (map.GetMapStyle() == VEMapStyle.Road) {
        map.SetMapStyle(VEMapStyle.Shaded);
    }
}

function getInfo() {
    var info;
    if (map.IsBirdseyeAvailable()) {
        var be = map.GetBirdseyeScene();

        info  = "ID: "          + be.GetID() + "\n";
        info += "thumbnail: "   + be.GetThumbnailFilename()+ "\n";
        info += "orientation: " + be.GetOrientation()+ "\n";
        info += "height: "      + be.GetHeight() + "\n";
        info += "width: "       + be.GetWidth() + "\n";

        var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

        info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

        // Check to see if the current birdseye view contains the pushpin pixel point.
        info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " + 
                be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";
        
        // Check to see if the current view contains the pushpin LatLong.
        info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";
        
        // This method may return null, depending on the selected view and map style.
        info += "latlong: " + map.PixelToLatLong(pixel);

        alert(info);
    } else {
        var center = map.GetCenter();

        info  = "Zoom level:\t" + map.GetZoomLevel() + "\n";
        info += "Latitude:\t"   + center.Latitude    + "\n";
        info += "Longitude:\t"  + center.Longitude;

        alert(info);
    }
}
         
function AddPin() {
    var shape = new VEShape(VEShapeType.Pushpin,UrsaMinor);
	//shape.SetCustomIcon(pinIcon); // if you wanted to set a custom icon
	shape.SetTitle("<div class=\"pinTitle\">Ursa Minor</div>");
	shape.SetDescription("<div class=\"pinDetails\">Honigklaverweg 29 <br />8670 Sint-Idesbald<br /><a href=\"http://www.ursaminor.be/\" title=\"Ursa Minor\" target=\"_blank\">http://www.ursaminor.be/</a></div>");
/*
	shape.SetCustomIcon(
               "<span style='font-family:Arial; font-size:x-small;" +
               "color:Black; background-color:White'>" +
               "<img src='../images/um_icon.gif'/>poly01</span>");
               */
	map.AddShape(shape);
	
	var shape2 = new VEShape(VEShapeType.Pushpin,plopsaLand);
	//shape.SetCustomIcon(pinIcon); // if you wanted to set a custom icon
	shape2.SetTitle("<div class=\"pinTitle\">Plopsaland</div>");
	shape2.SetDescription("<div class=\"pinDetails\">De Pannelaan 68<br />8660 De Panne<br /><a href=\"http://www.plopsa.be/\" title=\"Plopsaland\" target=\"_blank\">http://www.plopsa.be/</a></div>");
	map.AddShape(shape2);
	
	var shape3 = new VEShape(VEShapeType.Pushpin,delvauxMuseum);
	//shape.SetCustomIcon(pinIcon); // if you wanted to set a custom icon
	shape3.SetTitle("<div class=\"pinTitle\">Paul Delvaux Museum</div>");
	shape3.SetDescription("<div class=\"pinDetails\">Av. Paul Delvaux Laan 42<br />8670 Sint-Idesbald<br /><a href=\"http://www.delvauxmuseum.com/\" title=\"Paul Delvaux Museum\" target=\"_blank\">http://www.delvauxmuseum.com/</a></div>");
	map.AddShape(shape3);
	
	
	
	
	





}
