/**
 * Created by Johannes Rudolph <johannes.rudolph@gmx.com> on 16.02.2016.
 */

L.AISTrackLayer = L.FeatureGroup.extend({

    initialize: function(layers){
        L.LayerGroup.prototype.initialize.call(this, layers);
        this._intervalDeadObjs = setInterval(this._checkDeadObjects,1000,this);
        this.setRemoveTime(10);      
    },

    addAisData: function(mmsi,data){
        var trackMarker;
        if(this.getLayer(mmsi)){
            trackMarker = this.getLayer(mmsi);
            trackMarker.addData(data);
        }
        else{
            trackMarker = L.aisTrack( {
                contextmenu: true,
                contextmenuItems: [{
                    text: 'CPA Calculation',
                    index: 0
                }, {
                    separator: true,
                    index: 1
                }]});
            trackMarker.addData(data);
            this.addLayer(trackMarker);
        }
    },

    _checkDeadObjects: function(layerGroup) {
        var now = new Date();
        layerGroup.eachLayer(function(layer){
            if((now - layer.getLastUpdate()) > (layerGroup.getRemoveTime() * 60 * 1000 ))
                layerGroup.removeLayer(layer);
        });
    },

    setRemoveTime: function(minutes){
        this._removeMinutes = minutes;
    },

    getRemoveTime: function(){
        return this._removeMinutes;
    }
});

L.aisTrackLayer = function() {
    return new L.AISTrackLayer();
};
@@ -1212,24 +1212,592 @@
 %7D);%0A    %7D,%0A%0A
+    /**%0A     *%0A     * @param searchText%0A     * @returns %7B*%7D%0A     */%0A    searchTrack: function (searchText) %7B%0A        for(var i = 0 ; i %3C this.getLayers().length; i++)%7B%0A            var obj = this.getLayers()%5Bi%5D;%0A            if(obj.getMmsi() === parseInt(searchText))%7B%0A                return obj;%0A            %7D%0A            if(obj.getName().toLowerCase() === searchText.toLowerCase())%7B%0A                return obj;%0A            %7D%0A            if(obj.getImoNumber() === parseInt(searchText))%7B%0A                return obj;%0A            %7D%0A        %7D%0A        return false;%0A    %7D,%0A%0A
     setRemov

add searchTrack