示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Console.Write(hidEventName.Value);
        //Console.Write(hidEventValue.Value);
        //Fire event for Pushpin Move



        if (hidEventName.Value == "PushpinMoved")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinMoved(hidEventValue.Value);
        }
        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            if (GoogleMapObject == null)
            {
                GoogleMapObject = new GoogleObject();
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            }
        }
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>");
    }
示例#2
0
    public GoogleObject GetGoogleObject()
    {
        GoogleObject objGoogle = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];

        System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = new GoogleObject(objGoogle);
        return(objGoogle);
    }
        /// <summary>
        /// This checks to see whether or not the user passed the Google reCAPTCHA.
        /// </summary>
        /// <returns>A boolean indicating whether or not the user passed the Google reCAPTCHA.</returns>
        private bool CaptchaPass()
        {
            // First lets build a response message that requests from Google.
            string responseMessage = Request["g-recaptcha-response"];
            bool   validResponse   = false;
            // Now we need to actually request the information from google by passing it the message that was generated client-side. The secret=xxxxx part is a secret key generated by Google upon asking for a reCAPTCHA test.
            HttpWebRequest googleRequest = (HttpWebRequest)WebRequest.Create("https://www.google.com/recaptcha/api/siteverify?secret=6LdBE60UAAAAAA3sTZ2Rt02vhd9bcxTGffoc-4gq&response=" + responseMessage);

            try
            {
                // Now we have to get Google's response from the request we just sent. The response is actually a JSON object and we need to get the string from the key-value pair of "success":"xxxx".
                using (WebResponse googleResponse = googleRequest.GetResponse())
                    using (StreamReader responseReader = new StreamReader(googleResponse.GetResponseStream()))
                    {
                        string jsonResponse = responseReader.ReadToEnd();                                          // Read the response.
                        JavaScriptSerializer deserializer = new JavaScriptSerializer();                            // Create a serializer so we can deserialize the data.
                        GoogleObject         data         = deserializer.Deserialize <GoogleObject>(jsonResponse); // Deserialize the only part we care about into this object.
                        validResponse = Convert.ToBoolean(data.success);                                           // Convert the "true" or "false" string to a boolean to return.
                    }
            }
            catch (WebException)
            {
                return(false);     // Something problematic arose? Return false, then.
            }
            return(validResponse); // Otherwise, return the value that Google gave us back.
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Console.Write(hidEventName.Value);
        //Console.Write(hidEventValue.Value);
        //Fire event for Pushpin Move
        if (hidEventName.Value == "PushpinMoved")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinMoved(hidEventValue.Value);
        }
        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            if (GoogleMapObject == null)
            {
                GoogleMapObject = new GoogleObject();
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            }

        }
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>");
    }
示例#5
0
    public void RecenterMapComplete()
    {
        GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
        GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"];

        objGoogleNew.RecenterMap = false;
        objGoogleOld.RecenterMap = false;
    }
示例#6
0
    public void SetZoom(string pID, int pZoomLevel)
    {
        GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
        GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"];

        objGoogleNew.ZoomLevel = pZoomLevel;
        objGoogleOld.ZoomLevel = pZoomLevel;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Console.Write(hidEventName.Value);
        //Console.Write(hidEventValue.Value);
        //Fire event for Pushpin Move
        if (hidEventName.Value == "MapClicked")
        {
            string[] sLatLng = hidEventValue.Value.Split(new char[] { ',' }, StringSplitOptions.None);
            if (sLatLng.Length > 0)
            {
                double dLat = double.Parse(sLatLng[0]);
                double dLng = double.Parse(sLatLng[1]);
                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnMapClicked(dLat, dLng);
            }
        }
        if (hidEventName.Value == "PushpinClicked")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinClicked(hidEventValue.Value);
        }
        if (hidEventName.Value == "PushpinDrag")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinDrag(hidEventValue.Value);
        }
        if (hidEventName.Value == "ZoomChanged")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnZoomChanged(int.Parse(hidEventValue.Value));
        }


        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            if (GoogleMapObject == null)
            {
                GoogleMapObject = new GoogleObject();
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            }
        }
        string sScript = "<script src='http://maps.google.com/maps?file=api&amp;v=" + GoogleMapObject.APIVersion + ">&amp;key=" + GoogleMapObject.APIKey + "'  type='text/javascript'></script>";

        sScript += "<script type='text/javascript' src='GoogleMapAPIWrapper.js'></script>";
        sScript += "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>";
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", sScript);
    }
示例#8
0
    public void SetLatLon(string pID, double pLatitude, double pLongitude)
    {
        GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
        GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"];

        objGoogleNew.Points[pID].Latitude  = pLatitude;
        objGoogleNew.Points[pID].Longitude = pLongitude;
        objGoogleOld.Points[pID].Latitude  = pLatitude;
        objGoogleOld.Points[pID].Longitude = pLongitude;
    }
 // The method which fires the Event
 public void OnPushpinMoved(string pID)
 {
     // Check if there are any Subscribers
     if (PushpinMoved != null)
     {
         // Call the Event
         GoogleMapObject = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
         PushpinMoved(pID);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
     }
     else
     {
         GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
        }
    }
示例#12
0
 public GoogleObject(GoogleObject prev)
 {
     Points = GooglePoints.CloneMe(prev.Points);
     Polylines = GooglePolylines.CloneMe(prev.Polylines);
     Polygons = GooglePolygons.CloneMe(prev.Polygons);
     ZoomLevel = prev.ZoomLevel;
     ShowZoomControl = prev.ShowZoomControl;
     ShowMapTypesControl = prev.ShowMapTypesControl;
     Width = prev.Width;
     Height = prev.Height;
     MapType = prev.MapType;
     APIKey = prev.APIKey;
     ShowTraffic = prev.ShowTraffic;
     RecenterMap = prev.RecenterMap;
 }
 public GoogleObject(GoogleObject prev)
 {
     Points              = GooglePoints.CloneMe(prev.Points);
     Polylines           = GooglePolylines.CloneMe(prev.Polylines);
     Polygons            = GooglePolygons.CloneMe(prev.Polygons);
     ZoomLevel           = prev.ZoomLevel;
     ShowZoomControl     = prev.ShowZoomControl;
     ShowMapTypesControl = prev.ShowMapTypesControl;
     Width       = prev.Width;
     Height      = prev.Height;
     MapType     = prev.MapType;
     APIKey      = prev.APIKey;
     ShowTraffic = prev.ShowTraffic;
     RecenterMap = prev.RecenterMap;
 }
示例#14
0
 internal void createMapDataObject(ref GoogleObject GObj, List <VehicleMapInfo> list)
 {
     foreach (VehicleMapInfo info in list)
     {
         EDT.WebAPI.Models.Map.Google.GooglePoint point = new EDT.WebAPI.Models.Map.Google.GooglePoint();
         point.ToolTip   = info.VEHICLE_LABEL;
         point.ID        = info.VEHICLE_ID.ToString();
         point.Latitude  = info.VEHICLE_LATITUDE;
         point.Longitude = info.VEHICLE_LONGITUDE;
         point.IconImage = info.VEHICLE_TYPE_IMAGE_FILENAME.Split('.').First() + "/" + info.Vehicle_Online_Status;
         point.Heading   = info.VEHICLE_ANGLE;
         string temp1 = point.InfoHTML1;
         string temp2 = point.InfoHTML2;
         this.ParseCarsInfo(point, info.VEHICLE_TOOL_TIP);
         GObj.Points.Add(point);
     }
 }
示例#15
0
        //[RestAuthenticationAttribute]/*only with DB connection*/
        public IEnumerable <VehicleMapInfo> GetMapData(GetMapDataRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            //userData = GlobalData.GetSessionProperty(request.SID, userData.GetType());
            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            IEnumerable <VehicleMapInfo> vehicleMapInfo = null;

            if (userData != null)
            {
                vehicleMapInfo = MapsDAL.GetVehicleList(-180, -90, 180, 90, userData.CompanyId, request.VehicleIDs, -1).DataTableToList <VehicleMapInfo>();
                GoogleObject     GObj   = new GoogleObject();
                GetMapDataFacade facade = new GetMapDataFacade();
                facade.createMapDataObject(ref GObj, vehicleMapInfo.ToList());
            }
            return(vehicleMapInfo);
        }
示例#16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Console.Write(hidEventName.Value);
     //Console.Write(hidEventValue.Value);
     //Fire event for Pushpin Move
     if (hidEventName.Value == "PushpinMoved")
     {
         //Set event name to blank string, so on next postback same event doesn't fire again.
         hidEventName.Value = "";
         OnPushpinMoved(hidEventValue.Value);
     }
     if (!IsPostBack)
     {
         Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
     }
     else
     {
         GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
     }
 }
示例#17
0
 public GoogleObject(GoogleObject prev)
 {
     try
     {
         Directions          = prev.Directions;
         Points              = GooglePoints.CloneMe(prev.Points);
         Polylines           = GooglePolylines.CloneMe(prev.Polylines);
         Polygons            = GooglePolygons.CloneMe(prev.Polygons);
         ZoomLevel           = prev.ZoomLevel;
         ShowZoomControl     = prev.ShowZoomControl;
         ShowMapTypesControl = prev.ShowMapTypesControl;
         Width       = prev.Width;
         Height      = prev.Height;
         MapType     = prev.MapType;
         APIKey      = prev.APIKey;
         ShowTraffic = prev.ShowTraffic;
         RecenterMap = prev.RecenterMap;
         AutomaticBoundaryAndZoom = prev.AutomaticBoundaryAndZoom;
     }
     catch (Exception)
     {}
 }
        /// <summary>
        /// If you are interested in how this works, read the comments on the EventsWebForm.aspx.cs page.
        /// </summary>
        /// <returns></returns>
        private bool CaptchaPass()
        {
            string         responseMessage = Request["g-recaptcha-response"];
            bool           validResponse   = false;
            HttpWebRequest googleRequest   = (HttpWebRequest)WebRequest.Create("https://www.google.com/recaptcha/api/siteverify?secret=6LdBE60UAAAAAA3sTZ2Rt02vhd9bcxTGffoc-4gq&response=" + responseMessage);

            try
            {
                using (WebResponse googleResponse = googleRequest.GetResponse())
                    using (StreamReader responseReader = new StreamReader(googleResponse.GetResponseStream()))
                    {
                        string jsonResponse = responseReader.ReadToEnd();
                        JavaScriptSerializer deserializer = new JavaScriptSerializer();
                        GoogleObject         data         = deserializer.Deserialize <GoogleObject>(jsonResponse);
                        validResponse = Convert.ToBoolean(data.success);
                    }
            }
            catch (WebException)
            {
                return(false);
            }
            return(validResponse);
        }
示例#19
0
    public GoogleObject GetOptimizedGoogleObject()
    {
        GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
        GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"];
        GoogleObject objGoogle = new GoogleObject();

        if (objGoogleOld != null)
        {
            for (int i = 0; i < objGoogleNew.Points.Count; i++)
            {
                string pointStatus = "";
                GooglePoint NewPoint = objGoogleNew.Points[i];
                GooglePoint OldPoint = objGoogleOld.Points[NewPoint.ID];
                //if old point not found, means this is a new point.
                if (OldPoint == null)
                {
                    pointStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldPoint.Equals(NewPoint))
                    {
                        pointStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Points.Remove(OldPoint.ID);
                }
                if (pointStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewPoint.PointStatus = pointStatus;
                    objGoogle.Points.Add(NewPoint);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Points.Count; i++)
            {
                GooglePoint OldPoint = objGoogleOld.Points[i];
                OldPoint.PointStatus = "D";
                objGoogle.Points.Add(OldPoint);
            }

            //********************************************
            for (int i = 0; i < objGoogleNew.Polylines.Count; i++)
            {
                string lineStatus = "";
                GooglePolyline NewLine = objGoogleNew.Polylines[i];
                GooglePolyline OldLine = objGoogleOld.Polylines[NewLine.ID];
                //if old point not found, means this is a new point.
                if (OldLine == null)
                {
                    lineStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldLine.Equals(NewLine))
                    {
                        lineStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Polylines.Remove(OldLine.ID);
                }
                if (lineStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewLine.LineStatus = lineStatus;
                    objGoogle.Polylines.Add(NewLine);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Polylines.Count; i++)
            {
                GooglePolyline OldPolyline = objGoogleOld.Polylines[i];
                OldPolyline.LineStatus = "D";
                objGoogle.Polylines.Add(OldPolyline);
            }

            //********************************************
            for (int i = 0; i < objGoogleNew.Polygons.Count; i++)
            {
                string gonStatus = "";
                GooglePolygon NewGon = objGoogleNew.Polygons[i];
                GooglePolygon OldGon = objGoogleOld.Polygons[NewGon.ID];
                //if old point not found, means this is a new point.
                if (OldGon == null)
                {
                    gonStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldGon.Equals(NewGon))
                    {
                        gonStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Polygons.Remove(OldGon.ID);
                }
                if (gonStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewGon.Status = gonStatus;
                    objGoogle.Polygons.Add(NewGon);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Polygons.Count; i++)
            {
                GooglePolygon OldPolygon = objGoogleOld.Polygons[i];
                OldPolygon.Status = "D";
                objGoogle.Polygons.Add(OldPolygon);
            }
        }

        objGoogle.CenterPoint = objGoogleNew.CenterPoint;
        objGoogle.ZoomLevel = objGoogleNew.ZoomLevel;
        objGoogle.ShowTraffic = objGoogleNew.ShowTraffic;
        objGoogle.RecenterMap = objGoogleNew.RecenterMap;
        objGoogle.MapType = objGoogleNew.MapType;
        objGoogle.AutomaticBoundaryAndZoom = objGoogleNew.AutomaticBoundaryAndZoom;
        //Save new Google object state in session variable.
        //System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = objGoogleNew;
        System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = new GoogleObject(objGoogleNew);

        return objGoogle;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Console.Write(hidEventName.Value);
        //Console.Write(hidEventValue.Value);
        //Fire event for Pushpin Move
        if (hidEventName.Value == "MapClicked")
        {
            string[] sLatLng = hidEventValue.Value.Split(new char[] {','}, StringSplitOptions.None);
            if (sLatLng.Length > 0)
            {
                double dLat = double.Parse(sLatLng[0]);
                double dLng = double.Parse(sLatLng[1]);
                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnMapClicked(dLat,dLng);
            }
        }
        if (hidEventName.Value == "PushpinClicked")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinClicked(hidEventValue.Value);
        }
        if (hidEventName.Value == "PushpinDrag")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinDrag(hidEventValue.Value);
        }
        if (hidEventName.Value == "ZoomChanged")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnZoomChanged(int.Parse(hidEventValue.Value));
        }

        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            if (GoogleMapObject == null)
            {
                GoogleMapObject = new GoogleObject();
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            }

        }
        string sScript = "<script src='http://maps.google.com/maps?file=api&amp;v="+GoogleMapObject.APIVersion+">&amp;key="+GoogleMapObject.APIKey+"'  type='text/javascript'></script>";
        sScript += "<script type='text/javascript' src='GoogleMapAPIWrapper.js'></script>";
        sScript+= "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>";
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", sScript);
    }
示例#21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Console.Write(hidEventName.Value);
     //Console.Write(hidEventValue.Value);
     //Fire event for Pushpin Move
     if (hidEventName.Value == "PushpinMoved")
     {
         //Set event name to blank string, so on next postback same event doesn't fire again.
         hidEventName.Value = "";
         OnPushpinMoved(hidEventValue.Value);
     }
     if (!IsPostBack)
     {
         Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
     }
     else
     {
         GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        CultureInfo culture = new CultureInfo("en");

        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
        }
        else
        {
            GoogleMapObject            = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            GoogleMapObject.IsPostback = true;
            if (GoogleMapObject == null)
            {
                GoogleMapObject = new GoogleObject();
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            }
        }

        if (hidEventName.Value == "MapClicked")
        {
            string[] sLatLng = hidEventValue.Value.Split(new char[] { ',' }, StringSplitOptions.None);
            string   remp;
            string   remp2;
            if (sLatLng.Length > 0)
            {
                remp  = sLatLng[0].Replace(".", ",");
                remp2 = sLatLng[1].Replace(".", ",");
                // double dLat = double.Parse(sLatLng[0]);
                //double dLat = double.Parse(sLatLng[0]);
                //double dLng = double.Parse(sLatLng[1]);

                //double dLat = double.Parse(remp);
                //double dLng = double.Parse(remp2);

                double dLat = double.Parse(sLatLng[0], culture);
                double dLng = double.Parse(sLatLng[1], culture);

                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnMapClicked(dLat, dLng);
            }
        }
        if (hidEventName.Value == "PushpinClicked")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinClicked(hidEventValue.Value);
        }
        if (hidEventName.Value == "PushpinDrag")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnPushpinDrag(hidEventValue.Value);
        }
        if (hidEventName.Value == "ZoomChanged")
        {
            //Set event name to blank string, so on next postback same event doesn't fire again.
            hidEventName.Value = "";
            OnZoomChanged(int.Parse(hidEventValue.Value));
        }


        //API initialization is now moved to GoogleMapForASPNet.ascx page code.

        /*string sScript = "<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'></script>\n";
         * sScript += "<script type='text/javascript' src='GoogleMapAPIWrapper.js'></script>\n";
         * //sScript+= "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>";
         * // sScript += "<script language='javascript'>  </script>\n";
         * Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", sScript);*/
    }
示例#23
0
 public GoogleObject(GoogleObject prev)
 {
     try
     {
         Points = GooglePoints.CloneMe(prev.Points);
         Polylines = GooglePolylines.CloneMe(prev.Polylines);
         Polygons = GooglePolygons.CloneMe(prev.Polygons);
         ZoomLevel = prev.ZoomLevel;
         ShowZoomControl = prev.ShowZoomControl;
         ShowMapTypesControl = prev.ShowMapTypesControl;
         Width = prev.Width;
         Height = prev.Height;
         MapType = prev.MapType;
         APIKey = prev.APIKey;
         ShowTraffic = prev.ShowTraffic;
     }
     catch (Exception)
     {}
 }
        public void CreateGoogleMap()
        {
            GoogleMapObject = new GoogleObject();
            //Specify Center Point for map. Map will be centered on this point.
            ds = new DataSet();
            string mainApn = Request.QueryString["mainapn"].ToString();

            objreal.MainAPN = mainApn;
            ds = objreal.GetAddressInfo();

            if (ds.Tables[0].Rows.Count > 0)
            {
                //if ((ds.Tables[0].Rows[0]["Situs2"].ToString().Trim().ToUpper() == "VENTURA") && (ds.Tables[0].Rows[0]["Situs3"].ToString().Trim().ToUpper() == "CA"))
                //{
                //    imglogo1.ImageUrl = "https://pasimage.sitexdata.com/WebImage/ClientPhoto/rep/Admin_1.jpg";
                //    imglogo1.Height = 80;
                //    imglogo1.Width = 400;
                //    imglogo2.ImageUrl = "https://pasimage.sitexdata.com/WebImage/ClientPhoto/rep/Admin_1.jpg";
                //    imglogo2.Height = 80;
                //    imglogo2.Width = 400;
                //}
                //else
                //{
                //    imglogo1.ImageUrl = "~/images/defaultlogo.jpg";
                //    imglogo2.ImageUrl = "~/images/defaultlogo.jpg";
                //}
            }

            GooglePoint[] GP21     = new GooglePoint[ds.Tables[0].Rows.Count];
            GooglePoint   GPCenter = new GooglePoint();

            if (ds.Tables[0].Rows.Count > 0)
            {
                // lbladd.Text = ds.Tables[0].Rows[0]["Address"].ToString() + "," + ds.Tables[0].Rows[0]["Situs2"].ToString() + " " + ds.Tables[0].Rows[0]["Situs3"].ToString();
                //lbladd0.Text = ds.Tables[0].Rows[0]["Address"].ToString() + "," + ds.Tables[0].Rows[0]["Situs2"].ToString() + " " + ds.Tables[0].Rows[0]["Situs3"].ToString();
                _mainAddress = ds.Tables[0].Rows[0]["Address"].ToString()
                               + "," + ds.Tables[0].Rows[0]["Situs2"].ToString() + " "
                               + ds.Tables[0].Rows[0]["Situs3"].ToString();

                string Cen_cnt     = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Situs3"].ToString()) ? "" : ds.Tables[0].Rows[0]["Situs3"].ToString().Substring(0, 2);
                string Cen_post    = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Situs3"].ToString()) ? "" : ds.Tables[0].Rows[0]["Situs3"].ToString().Substring(2);
                string Cen_address = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Address"].ToString()) ? "" : ds.Tables[0].Rows[0]["Address"].ToString() + "-" + (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["Situs2"].ToString()) ? "" : ds.Tables[0].Rows[0]["Situs2"].ToString()) + "-" + Cen_cnt + " " + Cen_post;

                GPCenter.Address = Cen_address;

                if (GPCenter.GeocodeAddressV3())
                {
                    GoogleMapObject.CenterPoint = new GooglePoint("CenterPoint", GPCenter.Latitude, GPCenter.Longitude);
                }

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    //Char[] ch = ds.Tables[0].Rows[i]["Situs3"].ToString().ToCharArray();

                    /*string cnt = ds.Tables[0].Rows[i]["Situs3"].ToString().Substring(0, 2);
                     * string post = ds.Tables[0].Rows[i]["Situs3"].ToString().Substring(2);
                     * string address = ds.Tables[0].Rows[i]["Address"].ToString() + "-" + ds.Tables[0].Rows[i]["Situs2"].ToString() + "-" + cnt + " " + post;*/
                    string cnt     = string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Situs3"].ToString()) ? "" : ds.Tables[0].Rows[i]["Situs3"].ToString().Substring(0, 2);
                    string post    = string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Situs3"].ToString()) ? "" : ds.Tables[0].Rows[i]["Situs3"].ToString().Substring(2);
                    string address = string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Address"].ToString()) ? "" : ds.Tables[0].Rows[i]["Address"].ToString() + "-" + (string.IsNullOrEmpty(ds.Tables[0].Rows[i]["Situs2"].ToString()) ? "" : ds.Tables[0].Rows[i]["Situs2"].ToString()) + "-" + cnt + " " + post;

                    GP21[i]         = new GooglePoint();
                    GP21[i].ID      = i.ToString();
                    GP21[i].Address = address;

                    //GeocodeAddress() function will geocode address and set Latitude and Longitude of GP(GooglePoint) to it's respected value.
                    if (GP21[i].GeocodeAddressV3())
                    {
                        string name = "<table width='220px' height='30px'>";
                        name += "<tr>";
                        name += "<td width='10%'>";
                        name += "</td>";
                        name += "<td align='center' style='font-weight: bold;'>";
                        name += "<br />";
                        name += ds.Tables[0].Rows[i]["Address"].ToString() + "," + ds.Tables[0].Rows[i]["Situs2"].ToString() + " " + ds.Tables[0].Rows[i]["Situs3"].ToString();
                        name += "</td>";
                        name += "</tr>";
                        name += "<tr>";
                        name += "<td width='10%'>";
                        name += "</td>";
                        name += "<td width='90%' align='center'>";
                        //name += "Click <a target='_blank' href='http://maps.google.com/maps?cbp=12,,,0,-9.25&cbll=" + GP21[i].Latitude + "," + GP21[i].Longitude + "&panoid=&v=1&gl=us&output=svembed&layer=c'>";
                        //name += "Click <a target='_blank' href='http://maps.google.com/maps?cbp=12,,,0,-9.25&cbll=" + GP21[i].Latitude + "," + GP21[i].Longitude + "&panoid=&v=1&gl=us&layer=c'>";
                        name += "Click <a target='_blank' href='http://maps.google.com/maps?cbp=12,0,0,0,-9.25&cbll=" + GP21[i].Latitude + "," + GP21[i].Longitude + "&q=" + GP21[i].Latitude + "," + GP21[i].Longitude + "&panoid=&v=1&gl=us&output=classic&layer=c'>";
                        name += "Here</a> to see StreetView";
                        name += "</td>";
                        name += "</tr>";
                        name += "</table>";

                        //Once GP is geocoded, you can add it to google map.
                        GP21[i].InfoHTML = name;
                        if (i == 0)
                        {
                            GP21[i].IconImage = "images/marker1.gif";
                        }
                        else
                        {
                            GP21[i].IconImage = "images/marker.gif";
                        }
                        //Set GP as center point.


                        GoogleMapObject.CenterPoint = GP21[i];

                        //Add geocoded GP to GoogleMapObject
                        GoogleMapObject.Points.Add(GP21[i]);
                        GoogleMapObject.ZoomLevel = 17;
                        //Recenter map to GP.
                        GoogleMapObject.RecenterMap = true;
                        GoogleMapObject.APIVersion  = "3";
                    }
                }
            }
            else
            {
                _mainAddress = "Not Available";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GoogleMapObject.APIKey       = ConfigurationManager.AppSettings["GoogleAPIKey"];
                GoogleMapObject.APIVersion   = "2";
                GoogleMapObject.CenterPoint  = new GooglePoint("CenterPoint", 42.680872, 23.310297);
                Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;

                //GoogleMapObject.Points.Add(new GooglePoint("1", 43.65669, -79.45278));
                //GoogleMapObject.Width = "800px";
                //GoogleMapObject.Height = "600px";
            }
            else
            {
                GoogleMapObject            = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
                GoogleMapObject.IsPostback = true;
                if (GoogleMapObject == null)
                {
                    GoogleMapObject = new GoogleObject();
                    Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
                }
            }

            if (hidEventName.Value == "MapClicked")
            {
                string[] sLatLng = hidEventValue.Value.Split(new char[] { ',' }, StringSplitOptions.None);
                if (sLatLng.Length > 0)
                {
                    double dLat = double.Parse(sLatLng[0]);
                    double dLng = double.Parse(sLatLng[1]);
                    //Set event name to blank string, so on next postback same event doesn't fire again.
                    hidEventName.Value = "";
                    OnMapClicked(dLat, dLng);
                }
            }
            if (hidEventName.Value == "PushpinClicked")
            {
                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnPushpinClicked(hidEventValue.Value);
            }
            if (hidEventName.Value == "PushpinDrag")
            {
                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnPushpinDrag(hidEventValue.Value);
            }
            if (hidEventName.Value == "ZoomChanged")
            {
                //Set event name to blank string, so on next postback same event doesn't fire again.
                hidEventName.Value = "";
                OnZoomChanged(int.Parse(hidEventValue.Value));
            }


            //API initialization is now moved to GoogleMapForASPNet.ascx page code.

            /*string sScript = "<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'></script>\n";
             * sScript += "<script type='text/javascript' src='GoogleMapAPIWrapper.js'></script>\n";
             * //sScript+= "<script language='javascript'> if (window.DrawGoogleMap) { DrawGoogleMap(); } </script>";
             * // sScript += "<script language='javascript'>  </script>\n";
             * Page.ClientScript.RegisterStartupScript(Page.GetType(), "onLoadCall", sScript);*/
        }
示例#26
0
    public GoogleObject GetOptimizedGoogleObject()
    {
        GoogleObject objGoogleNew = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT"];
        GoogleObject objGoogleOld = (GoogleObject)System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"];
        GoogleObject objGoogle    = new GoogleObject();

        if (objGoogleOld != null)
        {
            for (int i = 0; i < objGoogleNew.Points.Count; i++)
            {
                string      pointStatus = "";
                GooglePoint NewPoint    = objGoogleNew.Points[i];
                GooglePoint OldPoint    = objGoogleOld.Points[NewPoint.ID];
                //if old point not found, means this is a new point.
                if (OldPoint == null)
                {
                    pointStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldPoint.Equals(NewPoint))
                    {
                        pointStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Points.Remove(OldPoint.ID);
                }
                if (pointStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewPoint.PointStatus = pointStatus;
                    objGoogle.Points.Add(NewPoint);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Points.Count; i++)
            {
                GooglePoint OldPoint = objGoogleOld.Points[i];
                OldPoint.PointStatus = "D";
                objGoogle.Points.Add(OldPoint);
            }

            //********************************************
            for (int i = 0; i < objGoogleNew.Polylines.Count; i++)
            {
                string         lineStatus = "";
                GooglePolyline NewLine    = objGoogleNew.Polylines[i];
                GooglePolyline OldLine    = objGoogleOld.Polylines[NewLine.ID];
                //if old point not found, means this is a new point.
                if (OldLine == null)
                {
                    lineStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldLine.Equals(NewLine))
                    {
                        lineStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Polylines.Remove(OldLine.ID);
                }
                if (lineStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewLine.LineStatus = lineStatus;
                    objGoogle.Polylines.Add(NewLine);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Polylines.Count; i++)
            {
                GooglePolyline OldPolyline = objGoogleOld.Polylines[i];
                OldPolyline.LineStatus = "D";
                objGoogle.Polylines.Add(OldPolyline);
            }

            //********************************************
            for (int i = 0; i < objGoogleNew.Polygons.Count; i++)
            {
                string        gonStatus = "";
                GooglePolygon NewGon    = objGoogleNew.Polygons[i];
                GooglePolygon OldGon    = objGoogleOld.Polygons[NewGon.ID];
                //if old point not found, means this is a new point.
                if (OldGon == null)
                {
                    gonStatus = "N"; //New
                }
                else
                {
                    //If old point found and old not equal to new point, means it's value is changed.
                    if (!OldGon.Equals(NewGon))
                    {
                        gonStatus = "C"; //Changed
                    }
                    //Remove found point from old object. This is to reduce iteration in next loop.
                    objGoogleOld.Polygons.Remove(OldGon.ID);
                }
                if (gonStatus != "")
                {
                    //If new point is changed, add it in list which is to be sent to client.
                    NewGon.Status = gonStatus;
                    objGoogle.Polygons.Add(NewGon);
                }
            }
            //Loop through rest of old points to mark them as deleted.
            for (int i = 0; i < objGoogleOld.Polygons.Count; i++)
            {
                GooglePolygon OldPolygon = objGoogleOld.Polygons[i];
                //        OldPolygon.Status = "D";
                objGoogle.Polygons.Add(OldPolygon);
            }
        }

        objGoogle.CenterPoint = objGoogleNew.CenterPoint;
        objGoogle.ZoomLevel   = objGoogleNew.ZoomLevel;
        objGoogle.ShowTraffic = objGoogleNew.ShowTraffic;
        objGoogle.RecenterMap = objGoogleNew.RecenterMap;
        objGoogle.MapType     = objGoogleNew.MapType;
        objGoogle.AutomaticBoundaryAndZoom = objGoogleNew.AutomaticBoundaryAndZoom;
        //Save new Google object state in session variable.
        //System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = objGoogleNew;
        System.Web.HttpContext.Current.Session["GOOGLE_MAP_OBJECT_OLD"] = new GoogleObject(objGoogleNew);

        return(objGoogle);
    }