﻿
function MapLayer()
{   
    var markerVisuals = new Array();
    this.SetMarkerVisuals = function(_markerVisuals) {markerVisuals = _markerVisuals;};
    this.GetMarkerVisuals = function() {return markerVisuals;};
    
    var markers = new Array();
    this.SetMarkers = function(_markers) {markers = _markers;};
    this.GetMarkers = function() {return markers;};
};

MapLayer.prototype.AddMarkerVisual = function(visualToAdd)
{
    this.GetMarkerVisuals().push(visualToAdd);
};

MapLayer.prototype.AddMarker = function(markerToAdd)
{
    this.GetMarkers().push(markerToAdd);
};

MapLayer.prototype.ShowOnMap = function(gmMap)
{
    for(var i = 0; i < this.GetMarkers().length; i++)        
    {
        gmMap.addOverlay(this.GetMarkers()[i].GetGmMarker());
    }
};

MapLayer.prototype.ShowOnMapAndPolygon = function(center)
{
    var mapGeometry = new MapGeometry();
    for(var i = 0; i < this.GetMarkers().length; i++)        
    {
        markerToCheck = this.GetMarkers()[i].GetGmMarker();
        latLonToCheck = this.GetMarkers()[i].GetGmMarker().getLatLng();
        this.GetMarkers()[i].GetData().Distance = mapGeometry.CalculateDistance(markerToCheck.getLatLng(), center);
        //if(!mapGeometry.IsPointInPolygon(latLonToCheck, polygon))
        
        //if(!bounds.containsLatLng(latLonToCheck))
        //{
            //markerToCheck.hide();
            //document.getElementById("trMarker_" + i).style.display = "none";
            //continue;
        //}
        markerToCheck.show();
        
        //document.getElementById("trMarker_" + i).style.display = "block";
    }
};




