/**
 * Created by taskaris on 2017-07-17.
 */

var layersmetadata_translation = {
    el_gr: {
        title: 'Μεταδεδομένα',
        alert: 'Δεν υπάρχουν μεταδεδομένα για το συγκεκριμένο επίπεδο...'
    },
    en_us: {
        title: 'Metadata',
        alert: 'No Metadata for that layer...'
    }
};

init_onload_fn.push(init_layersmetadata);

function init_layersmetadata() {
    _maptab_west_layer_layer_menu_components.push(new layersmetadata_menu);

}

var layersmetadata_menu = function () {
    return {
        text: layersmetadata_translation[language].title,
        iconCls: 'map_general_map',
        handler: function () {
            var _layerId = this.ownerCt._nodeId;
            layersmetadata_get(_layerId);
        }
    }
};

function layersmetadata_get(id) {

    var _layerObject = mapFindLayerById(id)._layerObject;

    if (_layerObject._layerMetadataURL) {
        var url = _layerObject._layerMetadataURL.split('&')[0];
        var id = _layerObject._layerMetadataURL.split('=').pop();
        var title = _layerObject._layerTitle;
        metadata_search_store_columns_showinfo(url,id,title);
    }
    else{
        alert(layersmetadata_translation[language].alert);
    }
}