source: tmcsimulator/trunk/webapps/js/cctvLayer.js @ 326

Revision 326, 2.5 KB checked in by jdalbey, 7 years ago (diff)

cptms v0.6.3 decomposed into modules

Line 
1function initCCTVbutton()
2{
3    var cctvBtnDiv = document.getElementById('cctvButton');
4    map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(cctvBtnDiv)
5    cctvBtnDiv.title = 'Click to toggle cctv view';
6    // Setup the click event listeners to toggle icon display
7    cctvBtnDiv.addEventListener('click', function()
8    {
9        cctv_showing = !cctv_showing;
10        // reveal or hide all the icons
11        cctvLayer.forEach(function(feature)
12        {
13            cctvLayer.overrideStyle(feature,
14            {
15                visible: cctv_showing
16            });
17        });
18        // Determine which button image to show
19        if (cctv_showing)
20        {
21            pic = "images/btnDepressed_CCTV.png"
22        }
23        else
24        {
25            pic = "images/btnReady_CCTV.png"
26        }
27        document.getElementById('cctvBtnImg').src = pic;
28    });
29}
30function makecctvIcon(nearVDS)
31{
32    var imgIcon = cctvIcon
33    if ((typeof map.data.getFeatureById(nearVDS)) == "undefined")
34    {
35        imgIcon = cctvIconWhite;
36    }
37    return imgIcon
38}
39function loadCCTVlayer()
40{
41    var imgTag = '<IMG WIDTH="700" SRC="images/';
42    cctv_infowindow = new google.maps.InfoWindow();
43    cctvLayer = new google.maps.Data();
44    cctvLayer.loadGeoJson(kCCTVfile);
45    cctvLayer.setStyle(function(feature)
46    {
47        // return the StyleOptions
48        return {
49            icon: makecctvIcon(feature.getProperty("nearVDS")),
50            title: feature.getId() + " " +feature.getProperty('locationName'),
51            visible: false 
52        };
53    });
54    cctvLayer.addListener('click', function(event)
55    {
56        //console.log("cctv layer was clicked at " + event.feature.getId());
57        cctvIndex = event.feature.getId();
58        //console.log(this.title + " is looking for " + this.nearVDS);
59        cctvLocation = event.feature.getProperty("locationName");
60        nearVDS = map.data.getFeatureById(event.feature.getProperty("nearVDS"));
61        currentColor = nearVDS.getProperty("color");
62        var imgDir = "CCTVFast/";
63        if (currentColor == "red" || currentColor == "yellow")
64        {
65            imgDir = "CCTVSlow/"
66        }
67
68        cctv_infowindow.setContent('<div style="font-weight:bold;font-family: monospace">' +  cctvIndex + "&nbsp;" + cctvLocation + "&nbsp;" +currentColor + "<BR>" + imgTag + imgDir + cctvIndex + '.jpg">' + "</div>");
69        cctv_infowindow.setPosition(event.feature.getGeometry().get());
70        cctv_infowindow.open(map);
71
72    });
73    cctvLayer.setMap(map);
74}
75
Note: See TracBrowser for help on using the repository browser.