﻿Type.registerNamespace("Mcw.Rijksoverheid.GoogleMaps");

Mcw.Rijksoverheid.GoogleMaps.MarkerGroup = function (element) {
    Mcw.Rijksoverheid.GoogleMaps.MarkerGroup.initializeBase(this, [element]);

    this._element = element;
    this._node = null;
    this._intID = null;
    this._strName = null;
    this._blIsUsableMoreThanOnce = null;
    this._arrMarkers = [];
    this._arrTagIDs = [];
}

Mcw.Rijksoverheid.GoogleMaps.MarkerGroup.prototype = {
    initialize: function () {
        Mcw.Rijksoverheid.GoogleMaps.MarkerGroup.callBaseMethod(this, 'initialize');
    },
    dispose: function () {
        Mcw.Rijksoverheid.GoogleMaps.MarkerGroup.callBaseMethod(this, 'dispose');
    },
    createMarkers: function () {
        // Set properties.
        this._intID = parseInt(this._node.getAttribute("id"));
        this._strName = this._node.getAttribute("name");
        this._arrTagIDs = this._node.getAttribute("tags").split(",");

        var arrMarkers = this._node.getElementsByTagName("marker");

        // Create collection of Tag instances.
        for (var i = 0; i < arrMarkers.length; i++)
            Array.add(this._arrMarkers, $create(Mcw.Rijksoverheid.GoogleMaps.Marker, { Node: arrMarkers[i], MarkerGroup: this }, null, null, document.createElement("div")));
    },
    // Show or hide all markers of this markergroup on map.
    showMarkerGroupOnMap: function (blShowMarkerGroupOnMap) {
        for (var i = 0; i < this._arrMarkers.length; i++)
            blShowMarkerGroupOnMap ? this._arrMarkers[i].showMarkerOnMap(true) : this._arrMarkers[i].showMarkerOnMap(false);
    },
    get_Node: function () {
        return this._node;
    },
    set_Node: function (value) {
        this._node = value;

        this.createMarkers();
    }
}

Mcw.Rijksoverheid.GoogleMaps.MarkerGroup.registerClass("Mcw.Rijksoverheid.GoogleMaps.MarkerGroup", Sys.UI.Control);
