How to add legend in Google Map JavaScript in code behind?

I am creating a amp project with the coordinates from database. I put my javascript in server side code in asp.net C#. I have created the map successfully but I can not show legend in the map.
I have get the marker from custom image file.

Please take a look at my code and advice me to solve my problem.

private void BuildScript(DataTable tbl, DataTable dtableCHT)
    {
        int i = 0;
        String Locations = "", Location = "", Latitude = "", Longitude = "", District = "", Total_Upazila = "", Img = "", ISA_NameB = "", DPM_NameB = "", DPM_Contact="", DistrictID="";
        foreach (DataRow r in tbl.Rows)
        {
            // bypass empty rows        
            if (r["Lat"].ToString().Trim().Length == 0)
                continue;

            Latitude = r["Lat"].ToString();
            Longitude = r["Long"].ToString();
            District = r["DistrictB"].ToString();
            Total_Upazila = r["Total_Upazila"].ToString();
            ISA_NameB = r["ISA_NameB"].ToString();
            DPM_NameB = r["DPM_NameB"].ToString();
            DPM_Contact= r["ContactNo"].ToString();
            DistrictID = r["DistrictID_DPE"].ToString();
            Img = "/img/icons/mapicon1.png";



            // create a line of JavaScript for marker on map for this record
            Locations += "['" + District + "'," + Latitude + " , " + Longitude + " , " + i + ",'" + Total_Upazila + "','" + ISA_NameB + "','" + Img + "','" + DPM_NameB + "','" + DPM_Contact + "','" + DistrictID + "'],";
            i++;
        }
        foreach (DataRow r in dtableCHT.Rows)
        {
            // bypass empty rows        
            if (r["Lat"].ToString().Trim().Length == 0)
                continue;

            Latitude = r["Lat"].ToString();
            Longitude = r["Long"].ToString();
            District = r["DistrictB"].ToString();
            Total_Upazila = r["Total_Upazila"].ToString();
            ISA_NameB = r["ISA_NameB"].ToString();
            DPM_NameB = r["DPM_NameB"].ToString();
            DPM_Contact = r["ContactNo"].ToString();
            DistrictID = r["DistrictID_DPE"].ToString();
            Img = "/img/icons/mapicon2.png";



            // create a line of JavaScript for marker on map for this record
            Locations += "['" + District + "'," + Latitude + " , " + Longitude + " , " + i + ",'" + Total_Upazila + "','" + ISA_NameB + "','" + Img + "','" + DPM_NameB + "','" + DPM_Contact + "','" + DistrictID + "'],";
            i++;
        }

        //JavaScript for Google api

        js.Text = @"<script>
                        function initMap() {

                            var locations = [ " + Locations + @"
                            ];

                            var map = new google.maps.Map(document.getElementById('dvMap'), {
                                zoom: 7,
                                center: new google.maps.LatLng(23.6850, 90.3563),
                                mapTypeId: google.maps.MapTypeId.ROADMAP
                            });

                            var infowindow = new google.maps.InfoWindow({});

                            var marker, i;

                            for (i = 0; i < locations.length; i++) {
                                marker = new google.maps.Marker({
                                    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                                    map: map,
                                    icon: locations[i][6]
                                });

                                google.maps.event.addListener(marker, 'click', (function (marker, i) {
                                    return function () {
                                        var html = ('<p><b>জেলা: </b>'+ locations[i][0]+'<br>'+'<b>মোট উপজেলার সংখ্যা: </b>'+locations[i][4]+'<br>'+'<b>বাস্তবায়ন সহায়ক সংস্থা: </b>'+locations[i][5]+'<br>'+'<b>জেলা প্রোগ্রাম ম্যানেজারের নাম: </b>'+locations[i][7]+'<br>'+'<b>মোবাইল নং: </b>'+locations[i][8]+'<br>'+'<a href=map_detail.aspx?param='+locations[i][9]+'>Click for Detail</a><br>'+'</p>')
                                        infowindow.setContent(html);
                                        infowindow.open(map, marker);
                                    }
                                })(marker, i));
                            }
                            map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(legend);
                        }
                </script>";

    }      

Thanks