private void loadGeofence(string ID)
    {
        double _lat, _lng;
        string deviceID = getDeviceID(Request.QueryString["unitID"].ToString());
        try
        {
            string _sql = "SELECT lat,long FROM tblGPRS WHERE deviceID = " + deviceID +
                          " AND recTime= (SELECT MAX(recTime) FROM tblGPRS WHERE deviceID = " + deviceID + " AND direction = 0);";

            ExecuteSQL exeSql = new ExecuteSQL();
            DataTable _dt = new DataTable();

            _dt = exeSql.ExecuteSQLQuery(_sql);

            _lng = double.Parse(_dt.Rows[0]["long"].ToString());
            _lat = double.Parse(_dt.Rows[0]["lat"].ToString());

            string _name = "";
            string _Rad = "";

            ProcessSafetyZone _pGeoData = new ProcessSafetyZone();
            Geofence _geoInput = new Geofence();

            _geoInput.ComID = int.Parse(Session["trkCompany"].ToString());
            if (ID != "")
                _geoInput.Id = int.Parse(ID);
            _geoInput.UnitID = int.Parse(Request.QueryString["unitID"].ToString());
            _pGeoData.GeoInfo = _geoInput;
            _pGeoData.LoadGeoData();

            DataSet _ds = new DataSet();
            _ds = _pGeoData.Ds;

            StringBuilder bfMarker = new StringBuilder();
            StringBuilder bfMarkerScript = new StringBuilder();

                if (_ds.Tables[0].Rows.Count > 0)
                {
                    _name = _ds.Tables[0].Rows[0]["name"].ToString();
                    _Rad = _ds.Tables[0].Rows[0]["radius"].ToString();
                    _txtEmail.Text = _ds.Tables[0].Rows[0]["email"].ToString();

                    try
                    {
                        _txtPhoneNumber.Text = _ds.Tables[0].Rows[0]["phoneNumber"].ToString();
                        bool isSMS = bool.Parse(_ds.Tables[0].Rows[0]["isSMS"].ToString());
                        if (isSMS)
                        {
                            _ckOnSMS.Checked = true;
                            _chkOffSMS.Checked = false;
                        }
                        else
                        {
                            _ckOnSMS.Checked = false;
                            _chkOffSMS.Checked = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (!_ckOnSMS.Checked)
                            _chkOffSMS.Checked = true;
                    }

                    if (_ds.Tables[0].Rows.Count > 0)
                    {

                        if (_ds.Tables[0].Rows[0]["isActive"].ToString() == "True")
                            _rdoON.Checked = bool.Parse(_ds.Tables[0].Rows[0]["isActive"].ToString());
                        else
                            _rdoOFF.Checked = true;
                    }

                    _txtZoneName.Text = _name;
                    _lblRadius.Text = _Rad;

                     double _radius = ((double.Parse(_Rad) / 1.60934) * 5280) / 3.2808399;

                    _Radius.Value = _ds.Tables[0].Rows[0]["Radius"].ToString();
                    _Lat.Value = _ds.Tables[0].Rows[0]["centerLat"].ToString();
                    _Long.Value = _ds.Tables[0].Rows[0]["centerLng"].ToString();

                    string _imageName = getImageName();

                    bfMarker.Append("<script language=\"javascript\">");

                    bfMarker.Append("   myMap = new GMap2(document.getElementById('map')); ");
                    bfMarker.Append(" var rad = document.getElementById('_Radius');");
                    bfMarker.Append(" var gName = document.getElementById('_txtGeofenceName');");
                    bfMarker.Append(" var _Lat = document.getElementById('_Lat');");
                    bfMarker.Append(" var _Long = document.getElementById('_Long'); ");

                    bfMarker.Append(" myMap.addControl(new GSmallMapControl());");
                    bfMarker.Append(" myMap.addControl(new GMapTypeControl());");
                    bfMarker.Append(" myMap.enableScrollWheelZoom();");
                    bfMarker.Append(" myMap.setCenter(new GLatLng(_Lat.value,_Long.value),15,G_HYBRID_MAP);");
                    bfMarker.Append(" GEvent.addListener(myMap,'click',clickedMap);");

                    bfMarker.Append(" var _radius=((rad.value/1.60934)*5280)/3.2808399;  ");
                    bfMarker.Append(" createCircle(new GLatLng(_Lat.value,_Long.value),_radius);");
                    bfMarker.Append(" clear=true;");

                    bfMarkerScript.Append(" cPoint=new GLatLng(" + _lat + "," + _lng + ");");
                    bfMarkerScript.Append(" var icon0 = new GIcon();");
                    bfMarkerScript.Append(" icon0.image = \\'../Icon/" + _imageName + ".png\\';");
                    bfMarkerScript.Append(" icon0.iconSize = new GSize(" + iconHeight + "," + iconWidth + ");");
                    bfMarkerScript.Append(" icon0.iconAnchor = new GPoint(" + iconHeight / 2 + "," + iconWidth / 2 + ");");
                    bfMarkerScript.Append(" icon0.infoWindowAnchor = new GPoint(15, 15);");
                    bfMarkerScript.Append(" icon0.infoShadowAnchor = new GPoint(18, 25);");
                    bfMarkerScript.Append(" var marker=new GMarker(cPoint,icon0);");

                    bfMarkerScript.Append(" myMap.addOverlay(marker,icon0);");

                    bfMarker.Append(" setTimeout('evalMarker(\"" + bfMarkerScript.ToString() + "\")',1000); ");
                    bfMarker.Append("</script>");
                    Page.RegisterStartupScript("marker", bfMarker.ToString());

             }

            else
            {
                try
                {
                    string _iconName = getImageName();

                    bfMarker.Append("<script language=\"javascript\">");

                    bfMarker.Append("   myMap = new GMap2(document.getElementById('map')); ");
                    bfMarker.Append(" myMap.addControl(new GSmallMapControl()); ");
                    bfMarker.Append(" myMap.addControl(new GMapTypeControl()); ");
                    bfMarker.Append(" myMap.enableScrollWheelZoom();");
                    bfMarkerScript.Append(" myMap.setCenter(new GLatLng(" + _lat + "," + _lng + "),14,G_HYBRID_MAP);");
                    bfMarker.Append(" GEvent.addListener(myMap,'click',clickedMap);");

                    bfMarkerScript.Append(" cPoint=new GLatLng(" + _lat + "," + _lng + ");");
                    bfMarkerScript.Append(" var icon0 = new GIcon();");
                    bfMarkerScript.Append(" icon0.image = \\'../Icon/" + _iconName + ".png\\';");
                    bfMarkerScript.Append(" icon0.iconSize = new GSize(" + iconHeight + "," + iconWidth + ");");
                    bfMarkerScript.Append(" icon0.iconAnchor = new GPoint(" + iconHeight / 2 + "," + iconWidth / 2 + ");");
                    bfMarkerScript.Append(" icon0.infoWindowAnchor = new GPoint(15, 15);");
                    bfMarkerScript.Append(" icon0.infoShadowAnchor = new GPoint(18, 25);");
                    bfMarkerScript.Append(" var marker=new GMarker(cPoint,icon0);");

                    bfMarkerScript.Append(" myMap.addOverlay(marker);");

                    bfMarker.Append(" setTimeout('evalMarker(\"" + bfMarkerScript.ToString() + "\")',100); ");
                    bfMarker.Append("</script>");
                    Page.RegisterStartupScript("marker", bfMarker.ToString());

                }

                catch (Exception ex)
                {
                    throw new Exception(ex.Message.ToString());
                }

            }
        }
        catch (Exception ex)
        {
            throw new Exception("loadGeofence(): " + ex.Message.ToString());

        }
    }