﻿// JScript File

//********************************************************************
//***************** Virtual Earth Code *******************************
//********************************************************************

//Definition of the Map Manager Object
function MapManagerVO()
{
    this._map = null;

    //Public Properties/Functions
    this.GUID = MM_GUID;
    this.Initialize = MM_Initialize;
    this.FindCity = MM_FindCity;
    this.AddPushPin = MM_AddPushPin;
    this.PanToLatLong = MM_PanToLatLong;
    this.SetZoomLevel = MM_SetZoomLevel;
    this.GetShapeByID = MM_GetShapeByID;
    this.ShowInfoBox = MM_ShowInfoBox;
    this.HideInfoBox = MM_HideInfoBox;
    this.SetCenterAndZoom = MM_SetCenterAndZoom;
    this.SetCenter = MM_SetCenter;
    this.AttachMouseOverEvent = MM_AttachMouseOverEvent;
}

function MM_SetCenter(latlng)
{
    this._map.SetCenter(latlng);
}

function MM_HideInfoBox()
{
    this._map.HideInfoBox();
}

function MM_ShowInfoBox(shape)
{
    this._map.ShowInfoBox(shape);
}

function MM_AttachMouseOverEvent(eventFunction)
{
    this._map.AttachEvent("onmouseover", eventFunction);
}

function MM_GetShapeByID(id)
{
    return this._map.GetShapeByID(id);
}

function MM_SetZoomLevel(zoom)
{
    this._map.SetZoomLevel(zoom);
}

function MM_SetCenterAndZoom(LatLng, zoom)
{
    this._map.SetCenterAndZoom(LatLng, zoom);
}

function MM_GUID()
{
    return this._map.GUID;
}

function MM_PanToLatLong(lat, lng)
{
    this._map.PanToLatLong(new VELatLong(lat, lng));
}

function MM_AddPushPin(id, lat, lng, title, details, IconTag)
{
    try
    {
        var point = new VELatLong(parseFloat(lat), parseFloat(lng));
        var shape = new VEShape(VEShapeType.Pushpin, point);
        shape.SetTitle(title);
        shape.SetDescription(details);
        if (IconTag != null)
            shape.SetCustomIcon(IconTag);
        this._map.AddShape(shape);
        this.PinCount += 1;
        return shape;
    }
    catch (ex)
    {
        return null;
    }
}

function MM_FindCity(CityStateName)
{
    this._map.Find(null, CityStateName, null, null, 0, null, true, true, true, true, _mapFindCallback);
}

function _mapFindCallback(ShapeLayer, FindResult, Place, HasMore)
{
    //A reference to the newly created VEShapeLayer Class object.
    //The VEFindResult Class array.
    //The VEPlace Class array.
    //A HasMore flag value that indicates whether there are more results after the current set.

    if (Place != null)
    {
        if (Place[0] != null)
        {

        }
    }
}

function MM_Initialize(divId)
{   
    this._map = new VEMap(divId);
    this._map.LoadMap();
}

//***********************************
//   End Map Manager
//***********************************
