﻿var settings = {
    mapWidgetOptions: {
        elements: { scalebar: true, fullExtent: true, overview:true },
        managedLayers: { vector:true, vector_2_5d:true, orthophoto:true, orthophoto_2005:true, 
        hybrid:true, hybrid_2005:true, hybrid_overlay:true, relief:true, parks:true },
        infoWindowOptions: { width:'320px', height:'160px', panIntoView:true }
    },
    layerViews: {
        vector: { title: { lt: 'Žemėlapis', en: 'Map' }, type: "bg" },
        vector_2_5d: { title: { lt: '2.5D žemėlapis', en: '2.5D map' }, type: "alt", parentId: "vector" },
        orthophoto: { title: { lt: 'Ortofoto', en: 'Orthophoto' }, type: "bg" },
        orthophoto_2005: { title: { lt: 'Senesnis ortofoto', en: 'Older orthophoto' }, type: "alt", parentId: "orthophoto" },
        hybrid: { title: { lt: 'Mišrus', en: 'Hybrid' }, type: "bg" },
        hybrid_2005: { title: { lt: 'Senesnis ortofoto', en: 'Older orthophoto' }, type: "alt", parentId: "hybrid" },
        relief: { title: { lt: 'Reljefas', en: 'Relief' }, type: "bg" },
        stops: {
            title: { lt: "Stotelės", en: "Public transport" },
            description: { lt: "Autobusų, troleibusų, maršrutinių taksi stotelės", en: "Buses, trolleybuses, minibuses stops" }
        },
        transport: {
            title: { lt: "Transportas", en: "Transport" },
            description: { lt: "Autobusų stotys, geležinkelio stotys, oro uostai, autoservisai, degalinės", en: "Bus stations, railway stations, airports, autoservices, gas stations" }
        },
        leisure: {
            title: { lt: "Laisvalaikis", en: "Leisure" },
            description: { lt: "Kavinės, barai, teatrai, kino teatrai, dailės galerijos, parduotuvės", en: "Cafes, pubs, theatres, cinemas, art galeries, shops" }
        },
        tourism: {
            title: { lt: "Turizmas", en: "Tourism" },
            description: { lt: "Turizmo informacijos centrai, maldos namai, muziejai, viešbučiai", en: "Tourism information centers, churches, museums, hotels" }
        },
        medical: {
            title: { lt: "Medicinos įstaigos", en: "Medical institutions" },
            description: { lt: "Ligoninės, privačios gydymo įstaigos, vaistinės", en: "Hospitals, drugstores" }
        },
        scholar: {
            title: { lt: "Mokymo įstaigos", en: "Scholar institutions" },
            description: { lt: "Darželiai, bendrojo lavinimo, profesinės, aukštosios mokyklos, sporto mokyklos", en: "Kindergartens, schools, universities, sport schools" }
        },
        zebra: {
            title: { lt: "\"Zebra belaidis\" interneto vietos", en: "\"Zebra belaidis\" internet places" },
            description: { lt: "Belaidžio interneto prieigos taškai", en: "Wireless Internet access points" }
        },
        other_services: {
            title: { lt: "Kitos paslaugos", en: "Other services" },
            description: { lt: "Bankai, policija, paštas, ambasados", en: "Banks, police stations, post offices, embassies" }
        },
        parks: {
            title: { lt: "Saugomos teritorijos", en: "Protected areas" },
            description: {lt:"Nacionaliniai, regioniniai parkai", en:"National and Regional Parks"}
        },
        panoramas: { title: { lt: "Panoraminės nuotraukos", en: "Panoramas"} },
        radars: { title: { lt: "Greičio matuokliai", en: "Speed cameras"} }
    },
    onInit: {
        widgets: [
            {
                id: "geocoding",
                dojoType: "hb.dijit.Locator",
                title: { lt: "Vietos paieška", en: "Place search" },
                options: {
                    map: { _ref: "map" },
                    withHelp: true,
                    withComments: true
                }
            }
        ]
    },
    onMapLoad: {
        widgets: [
            {
                id: "routing",
                dojoType: "hb.widgets.Routing",
                //dojoLayer: "" + dojo.moduleUrl("hb.widgets", "routing_layer.js"),
                title: { lt: "Maršrutai", en: "Directions" },
                options: {
                    map: { _ref: "map" },
                    serviceUrl: hbConfig.servicesProxyUrl + "mapslt_routing/NAServer/Route?cl=" + hbConfig.client,
                    poisLayerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/0?cl=" + hbConfig.client,
                    poisDynAttributes: {
                        title: function(a){ return hb.tr({lt:"Greičio matuoklis", en:"Speed camera"}) + (a.GreicioRib ? " ("+a.GreicioRib+" km/h)" : ""); }, 
                        icon: "images/markers/radar.png"
                    },
                    poisFilters: [
                        { title: { lt: "Greičio matuokliai", en: "Speed cameras" }, query: "1=1", active:true }
                    ]
                }
            },
            {
                id: "business",
                dojoType: "hb.widgets.Business",
                //dojoLayer: "" + dojo.moduleUrl("hb.widgets", "business_layer.js"),
                title: { lt: "Įmonės (beta)", en: "Business (beta)" },
                menuTitle: { lt: "Įmonės", en: "Business" },
                options: {
                    map: { _ref: "map" }
                }
            }/*,
            {
                id: "measure",
                dojoType: "hb.widgets.Measure",
                title: { lt: "Matavimo įrankiai", en: "Measure tools" },
                options: {
                    map: { _ref: "map" }
                },
                secondary: true
            }*/,
            {
                id: "bef",
                dojoType: "hb.widgets.BEF2",
                //dojoLayer: "" + dojo.moduleUrl("hb.widgets", "bef_layer.js"),
                title: { lt: "Pranešk apie skriaudžiamą gamtą", en: "Guarding Earth:<br/><span style='font-size:0.65em;'>mapping and solving environmental problems together</span>" },
                menuTitle: { lt: "Pranešk apie skriaudžiamą gamtą", en: "Guarding Earth" },
                options: {
                    map: { _ref: "map" },
                    pointsLayerUrl: "http://www.maps.lt/maps_services/bef/FeatureServer/0",
                    pointsCommentsLayerUrl: "http://www.maps.lt/maps_services/bef/FeatureServer/1"
                },
                secondary: true
            },
            {
                id: "sviesoforai",
                dojoType: "hb.widgets.SviesoforaiLT",
                title: { lt: "Vilniaus vairuotojų informavimo sistema", en: "Vilnius transport information system" },
                options: {
                    map: { _ref: "map" },
                    //speedServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_dynamic/MapServer/14",
                    speedServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_dynamic/MapServer",
                    camerasServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_cache/MapServer/0",
                    restrictionsPolygonsServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_dynamic/MapServer/13",
                    restrictionsPointsServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_dynamic/MapServer/12",
                    taxesServiceUrl: "http://www.sviesoforai.lt/ArcGIS/rest/services/Vilnius_sde_cache_infrastructure/MapServer/4",
					sviesoforaiUrl: "http://www.sviesoforai.lt/map"
                },
                secondary: true
            },
            {
                id: "influenza", 
                dojoType: "hb.widgets.Influenza", 
                title: {lt:"Gripas ir ŪVKTI", en:"Influenza"}, 
                options: {
                    map: { _ref: "map" },  
                    serviceUrl: "http://www.maps.lt/maps_services/flu/fluView/MapServer"
                }, 
                secondary: true
            },
            {
                id: "localSearch", 
                dojoType: "hb.widgets.LocalSearch", 
                title: {lt:"Paieška vietovėje", en:"Search locally"}, 
                options: {
                    map: { _ref: "map" }
                }, 
                secondary: true
            }
        ],
        queryLayers: {
            graphicsLayers: {
                /*business: {
                    _type: "hb.ClusteredGraphics",
                    _args: [
                        { _ref: "map" },
                        { _ref: "map.graphics" },
                        {
                            clusterDist: [[1000, 20], [3000, 150]],
                            clusterClass: "hb.GroupingClusterGraphic",
                            clusterOptions: { groupAttr: "classID" }
                        }
                    ]
                },*/
                layers: {
                    _type: "hb.GraphicsLayer",
                    _args: [{ addToMap: { _ref: "map" } }],
                    _target: "map._hbGfxLayers"
                },
                business: {
                    _type: "hb.ClusteredGraphics",
                    _args: [
                        { _ref: "map" },
                        { _ref: "map._hbGfxLayers" },
                        {
                            clusterDist: [[500, 20], [3000, 70]],
                            clusterClass: "hb.GroupingClusterGraphic2",
                            clusterOptions: { markerPictureUrl: "markers.ashx?cl=tstp" }
                        }
                    ]
                },
                zebra: {
                    _type: "hb.ClusteredGraphics",
                    _args: [
                        { _ref: "map" },
                        { _ref: "map._hbGfxLayers" },
                        {
                            clusterDist: [[500, 20], [3000, 200]],
                            clusterClass: "hb.GroupingClusterGraphic",
                            clusterOptions: { groupAttr: "classID" }
                        }
                    ]
                },
                parks: {
                    _type: "hb.ClusteredGraphics",
                    _args: [
                        { _ref: "map" },
                        { _ref: "map._hbGfxLayers" },
                        {
                            clusterDist: [[500, 20], [3000, 50]],
                            clusterClass: "hb.GroupingClusterGraphic2",
                            clusterOptions: { markerPictureUrl: "markers.ashx?cl=tstp" }
                        }
                    ]
                }
            },
            layers: {
                stops: {
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/16",
                    outFields: "OBJECTID,T_TOPO_NAME",
                    tipUrl: "map_tips.ashx?lang=${dojo.locale}&cl=tstp&type=stop&id=${OBJECTID}",
                    tileSize: 4000,
                    minScale: 6000,
                    symbol: {
                        _type: "esri.symbol.PictureMarkerSymbol",
                        _args: ['images/markers/stop.png', 20, 20]
                    }
                },
                zebra: {
                    graphics: "business",
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/2",
                    outFields: "T_ID,T_TOPO_NAME",
                    //tipUrl: "map_tips.ashx?lang=${dojo.locale}&cl=tstp&objID=wifi$${T_ID}", // tipUrl doesn't work with clustered graphics
                    dynAttributes: { classID: "zebra", info: "" }, // for clustering with business
                    tileSize: 4000,
                    minScale: 6000,
                    symbolTemplate: { url: "images/markers/wifi.png", width: '20', height: '20', yoffset: '10' }
                },
                ads: {
                    graphics: {
                        _type: "hb.ScaleDependantGraphics",
                        _args: [
                            { _ref: "map" },
                            { _ref: "map._hbGfxLayers" },
                            { minScaleAttr: "minScale", maxScaleAttr: "maxScale" }
                        ]
                    },
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/12",
                    outFields: "title,OBJECTID,imageWidth,imageHeight,imageName,minScale,maxScale,groupName",
                    tipUrl: "map_tips.ashx?lang=${dojo.locale}&cl=tstp&type=ad&id=${OBJECTID}",
                    tileSize: 8000000,
                    minScale: 30000000,
                    symbolTemplate: {
                        url: (hbConfig.adsImagesUrl || (hbConfig.servicesUrl + "images/_ads/")) + '${imageName}',
                        width: '${imageWidth}',
                        height: '${imageHeight}',
                        yoffset: '20'
                    },
                    tags: ["ad"],
                    gfxOptions: { tipSize: {w:'300px', h:'280px'} },
                    visible: true
                },
                panoramas: {
                    graphics: {
                        _type: "hb.ClusteredGraphics",
                        _args: [
                            { _ref: "map" },
                            { _ref: "map._hbGfxLayers" },
                            {
                                clusterDist: [[6000, 40]],
                                clusterSymbol: {
                                    _type: "esri.symbol.PictureMarkerSymbol",
                                    _args: ["images/panoramas_cluster.png", 40, 32]
                                }
                            }
                        ]
                    },
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/13",
                    outFields: "OBJECTID,title_${dojo.locale},thumb,url_${dojo.locale},authorName,authorUrl_${dojo.locale},thumbSmall",
                    tipTemplate: {
                        title: "${title_${dojo.locale}}",
                        info: "<div class='hbPanorama'>" +
                                "<div class='hbPanoramaImg'>" +
                                    "<a href='${url_${dojo.locale}}' target='_blank'>" +
                                    "<img src='${thumb}' style='height:100px' /></a><br />" +
                                    "<a href='${url_${dojo.locale}}' target='_blank'>${strings.panoramasView}</a>" +
                                "</div>" +
                            "${strings.panoramasAuthor}: <a href='${authorUrl_${dojo.locale}}' target='_blank'>${authorName}</a><br />" +
                            "${strings.panoramasSource}: <a href='http://www.turizmas.info' target='_blank'>www.turizmas.info</a></div>"
                    },
                    tileSize: 8000000,
                    minScale: 3000000,
                    symbolTemplate: { url: '${thumbSmall}', width: "30", height: "22" }
                },
                business: {
                    graphics: "business",
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/14",
                    outFields: "classID,title_${dojo.locale},info_${dojo.locale}",
                    dynAttributes: {"group":function(attrs){  
                        switch (attrs.classID){
                            case 6: return 5; break; // merge medical institutions
                            case 23: case 24: case 25: case 26: return 22; break; // merge scholar institutions
                            default: return attrs.classID;
                        }
                    }},
                    tipTemplate: { title: "${title_${dojo.locale}}", info: "${info_${dojo.locale}}" },
                    tileSize: 1500,
                    minScale: 6000,
                    tags: ["business"],
                    symbolTemplate: { url: "images/markers/topo_${group}.png", width: '20', height: '20', yoffset: '10' }
                },
                parks: {
                    graphics: "parks",
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/15",
                    outFields: "Pavadinima,classID",
                    tipTemplate: { title: "${Pavadinima}", info: "" },
                    tileSize: 8000,
                    minScale: 16000,
                    symbolTemplate: { url: "images/markers/topo_${classID}.png", width: '20', height: '20' },
                    visible: true
                },
                radars: {
                    layerUrl: hbConfig.servicesProxyUrl + "mapslt_query/MapServer/0",
                    outFields: "OBJECTID,Tipas,GreicioRib",
                    dynAttributes: { info: function(attrs){ return attrs.GreicioRib ? "Leistinas greitis: "+attrs.GreicioRib+" km/h" : ""; }},
                    tipTemplate: { title: "${Tipas}", info: "${info}" },
                    tileSize: 8000000,
                    minScale: 3000000,
                    symbolTemplate: { url: "images/markers/radar.png", width: '20', height: '20' },
                    visible: false
                }
            },
            views: {
                stops: {
                    layers: [{ id: "stops"}],
                    visible: true,
                    minScale: 6000
                },
                transport: {
                    layers: [{ id: "business", where: "classID in (4,7,8,9,10)"}],
                    minScale: 6000
                },
                leisure: {
                    layers: [{ id: "business", where: "classID in (12,16,17,18,21)"}],
                    minScale: 6000
                },
                tourism: {
                    layers: [{ id: "business", where: "classID in (13,14,15,20)"}],
                    minScale: 6000
                },
                medical: {
                    layers: [{ id: "business", where: "classID in (5,6,11)"}],
                    minScale: 6000
                },
                scholar: {
                    layers: [{ id: "business", where: "classID in (22,23,24,25,26)"}],
                    minScale: 6000
                },
                zebra: {
                    layers: [{ id: "zebra"}],
                    visible: true,
                    minScale: 6000
                },
                other_services: {
                    layers: [{ id: "business", where: "classID in (1,19,2,3,121)"}],
                    minScale: 6000
                },
                panoramas: {
                    layers: [{ id: "panoramas"}]
                },
                parks: {
                    layers: [{ id: "parks"}]
                },
                radars: {
                    layers: [{ id: "radars"}]
                }
            }
        }
    }
};

