﻿var eMapType = { Regular:0, Satelite:1, Hybrid:2 };

function YahooMap() {
}

YahooMap.prototype.map = null;

YahooMap.prototype.CreateMap = function(mapContainerId) {
    this.map = new YMap(document.getElementById(mapContainerId));
}

YahooMap.prototype.AddZoomControl = function(isLongZoom) {
    if (isLongZoom)
        this.map.addZoomLong();
    else
        this.map.addZoomShort();
}

YahooMap.prototype.AddPanControl = function() {
    this.map.addPanControl(); 
}

YahooMap.prototype.AddTypeControl = function() {
    this.map.addTypeControl();
}

YahooMap.prototype.SetMapType = function(mapType) {
    if(mapType == 0)
        this.map.setMapType(YAHOO_MAP_REG);
    else if(mapType == 1)
        this.map.setMapType(YAHOO_MAP_SAT);
    else if(mapType == 2)
        this.map.setMapType(YAHOO_MAP_HYB);
}

YahooMap.prototype.AddMapMarker = function(latitude, longitude, markerMarkup, labelMarkup, imageSrc, imageHeight, imageWidth, popupOffsetX, popupOffsetY)
{
    var newMapMarker;
    var newGeoPoint = new YGeoPoint(latitude, longitude);
    if(imageSrc != null)
    {
        var newImage = new YImage();
        newImage.src = imageSrc;
        newImage.size = new YSize(imageHeight, imageWidth);
        newImage.offsetSmartWindow = new YCoordPoint(popupOffsetX, popupOffsetY);
        newMapMarker = new YMarker(newGeoPoint, newImage);
    }
    else
        newMapMarker = new YMarker(newGeoPoint);
    
    if(markerMarkup != null)
        YEvent.Capture(newMapMarker, EventsList.MouseClick, function(){newMapMarker.openSmartWindow(markerMarkup);});
    if(labelMarkup != null)
        newMapMarker.addLabel(labelMarkup);
        
    this.map.addOverlay(newMapMarker);
}

YahooMap.prototype.SetCenterAndZoomCity = function(cityDescription, zoomLevel){
    this.map.drawZoomAndCenter(cityDescription, zoomLevel);
}

YahooMap.prototype.SetCenterAndZoom = function(latitude, longitude, zoomLevel){
    var newGeoPoint = new YGeoPoint(latitude, longitude);
    this.map.drawZoomAndCenter(newGeoPoint, zoomLevel);
}