﻿ 
 var map = null;
 var initLoc = new VELatLong(51.056192,3.461165,0);
 var zele = new VELatLong(51.056192,4.035072,0);
 var overmere = new VELatLong(51.040315,3.952332,0);
 var waregem = new VELatLong(50.888316,3.461165,0);
 var koksijde = new VELatLong(51.104148,2.609665,0);
 var pinPoint = null;
 var pinPixel = null;
                  
function GetMap() {
    map = new VEMap('myMap');
	map.LoadMap(initLoc, 8, 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 shape1 = new VEShape(VEShapeType.Pushpin,zele);
	shape1.SetTitle("<div class=\"pinTitle\">Manipura te Zele</div>");
	shape1.SetDescription("<div class=\"pinDetails\">Veldeken 198<br />9240 Zele<br /><a href=\"http://www.manipura.be/\" title=\"http://www.manipura.be\" target=\"_blank\">http://www.manipura.be/</a></div>");
	map.AddShape(shape1);
	
	var shape2 = new VEShape(VEShapeType.Pushpin,waregem);
	shape2.SetTitle("<div class=\"pinTitle\">Manipura te Waregem</div>");
	shape2.SetDescription("<div class=\"pinDetails\">Driekavenstraat 7<br />8790 Waregem<br /><a href=\"http://www.manipura.be/\" title=\"http://www.manipura.be\" target=\"_blank\">http://www.manipura.be/</a></div>");
	map.AddShape(shape2);
	
	var shape3 = new VEShape(VEShapeType.Pushpin,overmere);
	shape3.SetTitle("<div class=\"pinTitle\">Manipura te Overmere</div>");
	shape3.SetDescription("<div class=\"pinDetails\">Burgemeester de Lausnaystraat 67<br />9290 Overmere<br /><a href=\"http://www.manipura.be/\" title=\"http://www.manipura.be\" target=\"_blank\">http://www.manipura.be/</a></div>");
	map.AddShape(shape3);
	
	var shape4 = new VEShape(VEShapeType.Pushpin,koksijde);
	shape4.SetTitle("<div class=\"pinTitle\">Manipura te Koksijde</div>");
	shape4.SetDescription("<div class=\"pinDetails\">Sloepenlaan 2<br />8670 Koksijde<br /><a href=\"http://www.manipura.be/\" title=\"http://www.manipura.be\" target=\"_blank\">http://www.manipura.be/</a></div>");
	map.AddShape(shape4);

}