﻿var map = null;
var LA = new VELatLong(50.644304, 3.138463);
var pinPoint = null;
var pinPixel = null;
       
function GetMap()
{
    if(document.getElementById('myMap'))
    {
        map = new VEMap('myMap');
        map.LoadMap(LA, 10, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);

        AddPin(50.644304,3.138463,null,'Wygwam France','1 rue de la Perfromance, Bâtiment B4, 59650 Villeneuve d\'Ascq, France');
        AddPin(50.748240,3.217709,null,'Wygwam Belux','64 rue Victor Corne, B-7700 Mouscron, Belgique');
    }
}

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(lat, lon, iconurl, title, desc)
{
    var shape = 
        new VEShape(VEShapeType.Pushpin, 
        new VELatLong(lat,lon));
    shape.SetTitle(title);
    shape.SetDescription(desc);
    map.AddShape(shape);
}