﻿var label_marker_manager = null;
var toronto_fixed = null;

var map_labels_level1 = {"labels" : [    
        {"trra_id": "CH1014" , "height": "11", "width" : "26", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Ajax.png", "geom" : "POINT(-79.02029596290 43.85704658440)", "latitude" : 43.85704658440, "longitude" : -79.02029596290},    
        {"trra_id": "CH1035" , "height": "14", "width" : "36", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Aurora.png", "geom" : "POINT(-79.45039604060 44.00875446790)", "latitude" : 44.00875446790, "longitude" : -79.45039604060},     
        {"trra_id": "CH1044" , "height": "14", "width" : "49", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Brampton.png", "geom" : "POINT(-79.75992393840 43.43.68750942460)", "latitude" : 43.68750942460, "longitude" : -79.75992393840},    
        {"trra_id": "CH1016" , "height": "14", "width" : "32", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Brock.png", "geom" : "POINT(-79.03871592680 44.35252623550)", "latitude" : 44.35252623550, "longitude" : -79.03871592680},
        {"trra_id": "CH1020" , "height": "14", "width" : "51", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Burlington.png", "geom" : "POINT(-79.79888305420 43.32789639150)", "latitude" : 43.32789639150, "longitude" : -79.79888305420},      
        {"trra_id": "CH1046" , "height": "14", "width" : "43", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Caledon.png", "geom" : "POINT(-79.85778202110 43.87770576820)", "latitude" : 43.87770576820, "longitude" : -79.85778202110},    
        {"trra_id": "CH1026" , "height": "14", "width" : "53", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Cambridge.png", "geom" : "POINT(-80.31464596070 43.36363235070)", "latitude" : 43.36363235070, "longitude" : -80.31464596070},        
        {"trra_id": "CH1005" , "height": "14", "width" : "84", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/CentreWellington.png", "geom" : "POINT(-80.43018900270 43.68528020650)", "latitude" : 43.68528020650, "longitude" : -80.43018900270},
        {"trra_id": "CH1013" , "height": "14", "width" : "51", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Clarington.png", "geom" : "POINT(-78.72097793620 43.93193381190)", "latitude" : 43.93193381190, "longitude" : -78.72097793620},      
        {"trra_id": "CH1010" , "height": "14", "width" : "84", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/DurhamRegion.png", "geom" : "POINT(-78.94241404870 43.91179203390)", "latitude" : 43.91179203390, "longitude" : -78.94241404870},        
        {"trra_id": "CH1036" , "height": "14", "width" : "80", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/EastGwillimbury.png", "geom" : "POINT(-79.44190108230 44.10354810050)", "latitude" : 44.10354810050, "longitude" : -79.44190108230},        
        {"trra_id": "CH1003" , "height": "14", "width" : "23", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Erin.png", "geom" : "POINT(-80.07016499580 43.77718449370)", "latitude" : 43.77718449370, "longitude" : -80.07016499580},    
        {"trra_id": "CH1037" , "height": "14", "width" : "46", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Georgina.png", "geom" : "POINT(-79.43623205350 44.29860307610)", "latitude" : 44.29860307610, "longitude" : -79.43623205350},    
        {"trra_id": "CH1002" , "height": "14", "width" : "41", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/guelph.png", "geom" : "POINT(-80.24827496720 43.53005053850)", "latitude" : 43.53005053850, "longitude" : -80.24827496720},
        {"trra_id": "CH1006" , "height": "14", "width" : "79", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/GuelphEramosa.png", "geom" : "POINT(-80.19170901240 43.64561875140)", "latitude" : 43.64561875140, "longitude" : -80.19170901240},
        {"trra_id": "CH1021" , "height": "14", "width" : "58", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/HaltonHills.png", "geom" : "POINT(-79.93188601100 43.63948610720)", "latitude" : 43.63948610720, "longitude" : -79.93188601100},       
        {"trra_id": "CH1019" , "height": "16", "width" : "77", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/HaltonRegion.png", "geom" : "POINT(-79.74578608540 43.41619557250)", "latitude" : 43.41619557250, "longitude" : -79.74578608540},        
        {"trra_id": "CH1024" , "height": "13", "width" : "50", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Hamilton.png", "geom" : "POINT(-79.87337608220 43.25799348090)", "latitude" : 43.25799348090, "longitude" : -79.87337608220},        
        {"trra_id": "CH1042" , "height": "14", "width" : "27", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/king.png", "geom" : "POINT(-79.5211489526 43.9324959336)", "latitude" : 43.9324959336, "longitude" : -79.5211489526},
        {"trra_id": "CH1027" , "height": "10", "width" : "48", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Kitchener.png", "geom" : "POINT(-80.47409606920 43.43658014780)", "latitude" : 43.43658014780, "longitude" : -80.47409606920},    
        {"trra_id": "CH1007" , "height": "14", "width" : "46", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/mapleton.png", "geom" : "POINT(-80.6853560179 43.7749342827)", "latitude" : 43.7749342827, "longitude" : -80.6853560179},
        {"trra_id": "CH1038" , "height": "12", "width" : "46", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Markham.png", "geom" : "POINT(-79.33674993730 43.85446812320)", "latitude" : 43.85446812320, "longitude" : -79.33674993730},    
        {"trra_id": "CH1022" , "height": "14", "width" : "32", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Milton.png", "geom" : "POINT(-79.88354499680 43.51263194590)", "latitude" : 43.51263194590, "longitude" : -79.88354499680},    
        {"trra_id": "CH1004" , "height": "14", "width" : "29", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/minto.png", "geom" : "POINT(-80.8663569965 43.9382675213)", "latitude" : 43.9382675213, "longitude" : -80.8663569965},
        {"trra_id": "CH1045" , "height": "14", "width" : "62", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/mississauga.png", "geom" : "POINT(-79.64437804190 43.59104765090)", "latitude" : 43.59104765090, "longitude" : -79.64437804190},
        {"trra_id": "CH1039" , "height": "14", "width" : "56", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Newmarket.png", "geom" : "POINT(-79.46022401060 44.06734301270)", "latitude" : 44.06734301270, "longitude" : -79.46022401060},    
        {"trra_id": "CH1029" , "height": "14", "width" : "72", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/northdumfries.png", "geom" : "POINT(-80.3534619697 43.3193294203)", "latitude" : 43.3193294203, "longitude" : -80.3534619697},
        {"trra_id": "CH1023" , "height": "14", "width" : "40", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Oakville.png", "geom" : "POINT(-79.68766606390 43.46973115920)", "latitude" : 43.46973115920, "longitude" : -79.68766606390},    
        {"trra_id": "CH1011" , "height": "12", "width" : "39", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/oshawa.png", "geom" : "POINT(-78.84916747540 43.88856755930)", "latitude" : 43.88856755930, "longitude" : -78.84916747540},
        {"trra_id": "CH1043" , "height": "14", "width" : "65", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/PeelRegion.png", "geom" : "POINT(-79.72186393190 43.72132644310)", "latitude" : 43.72132644310, "longitude" : -79.72186393190},        
        {"trra_id": "CH1012" , "height": "14", "width" : "47", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Pickering.png", "geom" : "POINT(-79.08373299710 43.83625580890)", "latitude" : 43.83625580890, "longitude" : -79.08373299710},    
        {"trra_id": "CH1008" , "height": "14", "width" : "43", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Puslinch.png", "geom" : "POINT(-80.09734900090 43.43513230580)", "latitude" : 43.43513230580, "longitude" : -80.09734900090},    
        {"trra_id": "CH1040" , "height": "14", "width" : "67", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/RichmondHill.png", "geom" : "POINT(-79.43786302450 43.87690243870)", "latitude" : 43.8375, "longitude" : -79.3789},    
        {"trra_id": "CH1017" , "height": "14", "width" : "40", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Scugog.png", "geom" : "POINT(-78.89445694700 44.17240792430)", "latitude" : 44.17240792430, "longitude" : -78.89445694700},    
        {"trra_id": "CH1047" , "height": "14", "width" : "46", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/toronto.png", "geom" : "POINT(-79.38390701960 43.65607808280)", "latitude" : 43.66607808280, "longitude" : -79.32390701960, "alt_latitude" : 43.66607808280, "alt_longitude" : -79.35390701960},
        {"trra_id": "CH1018" , "height": "14", "width" : "45", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Uxbridge.png", "geom" : "POINT(-79.12291896420 44.10864566140)", "latitude" : 44.10864566140, "longitude" : -79.12291896420},    
        {"trra_id": "CH1034" , "height": "14", "width" : "44", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Vaughan.png", "geom" : "POINT(-79.44991597600 43.81312752030)", "latitude" : 43.8548, "longitude" : -79.507},    
        {"trra_id": "CH1028" , "height": "11", "width" : "44", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Waterloo.png", "geom" : "POINT(-80.52561120930 43.47961573020)", "latitude" : 43.47961573020, "longitude" : -80.52561120930},    
        {"trra_id": "CH1025" , "height": "12", "width" : "89", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/waterlooregion.png", "geom" : "POINT(-80.48138440190 43.45901177920)", "latitude" : 43.45901177920, "longitude" : -80.48138440190},
        {"trra_id": "CH1030" , "height": "14", "width" : "49", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Wellesley.png", "geom" : "POINT(-80.76449801730 43.47971126480)", "latitude" : 43.47971126480, "longitude" : -80.76449801730},    
        {"trra_id": "CH1001" , "height": "14", "width" : "99", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/WellingtonCounty.png", "geom" : "POINT(-80.24747202640 43.55583240220)", "latitude" : 43.55583240220, "longitude" : -80.24747202640},         
        {"trra_id": "CH1009" , "height": "14", "width" : "80", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/WellingtonNorth.png", "geom" : "POINT(-80.63215703260 43.89962920390)", "latitude" : 43.89962920390, "longitude" : -80.63215703260},         
        {"trra_id": "CH1015" , "height": "12", "width" : "35", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/Whitby.png", "geom" : "POINT(-78.95167370540 43.88820137180)", "latitude" : 43.88820137180, "longitude" : -78.95167370540},    
        {"trra_id": "CH1041" , "height": "14", "width" : "104", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/WhitchurchStouffville.png", "geom" : "POINT(-79.24548407130 43.97326949010)", "latitude" : 43.97326949010, "longitude" : -79.24548407130},    
        {"trra_id": "CH1031" , "height": "14", "width" : "36", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/wilmot.png", "geom" : "POINT(-80.67210300020 43.40547501260)", "latitude" : 43.40547501260, "longitude" : -80.67210300020},
        {"trra_id": "CH1032" , "height": "14", "width" : "48", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/woolwich.png", "geom" : "POINT(-80.55920898 43.6001736719)", "latitude" : 43.6001736719, "longitude" : -80.55920898},
        {"trra_id": "CH1033" , "height": "14", "width" : "68", "image" : "http://imap.esolutionsgroup.ca/trra_staging/Images/map_labels/png8/YorkRegion.png", "geom" : "POINT(-79.47889795960 44.04521975980)", "latitude" : 44.04521975980, "longitude" : -79.47889795960}] };     

   
function addLabels()
{
        var label_markers = [];
        if (label_marker_manager)
            label_marker_manager.clearMarkers();      
    
        var label_length = map_labels_level1.labels.length;
        for (var i=0; i < label_length; i++) {
            var pt = new GLatLng(map_labels_level1.labels[i].latitude, map_labels_level1.labels[i].longitude);
            var marker = new GMarker(pt, {icon: createGIcon(map_labels_level1.labels[i]), title: map_labels_level1.labels[i].trra_id});
           
            GEvent.addListener(marker, "click", function(latlng) {
                previous_click = latlng;               
                handleRequest({marker_type:"LABEL", request_type:"LOAD_DETAILS", param_1: this.getTitle()});
            });
			
			if (map_labels_level1.labels[i].trra_id == "CH1047")
				toronto_fixed = marker;
			
            label_markers.push(marker);
        }
        label_marker_manager = new MarkerManager(map);                     
        label_marker_manager.addMarkers(label_markers, MinZoom);                    
        label_marker_manager.refresh();
}

function createGIcon(obj)
{
	var gTempIcon = new GIcon()
	gTempIcon.image = obj.image;
	gTempIcon.iconSize = new GSize(obj.width,obj.height);
	gTempIcon.iconAnchor = new GPoint(obj.width/2,obj.height);
	return gTempIcon;
}