protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //You must specify Google Map API Key for this component. You can obtain this key from http://code.google.com/apis/maps/signup.html
            //For samples to run properly, set GoogleAPIKey in Web.Config file.
            GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];

            //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
            GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; // You can also specify percentage(e.g. 80%) here
            GoogleMapForASPNet1.GoogleMapObject.Height = "600px";

            //Specify initial Zoom level.
            GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 14;

            //Specify Center Point for map. Map will be centered on this point.
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", 43.66619, -79.44268);

            //Add pushpins for map.
            //This should be done with intialization of GooglePoint class.
            //ID is to identify a pushpin. It must be unique for each pin. Type is string.
            //Other properties latitude and longitude.

            GooglePoint GP1 = new GooglePoint();
            GP1.ID = "GP1";
            GP1.Latitude = 43.65669;
            GP1.Longitude = -79.44268;
            GP1.InfoHTML = "This is point 1";
            GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1);

            GooglePoint GP2 = new GooglePoint();
            GP2.ID = "GP2";
            GP2.Latitude = 43.66619;
            GP2.Longitude = -79.44268;
            GP2.InfoHTML = "This is point 2";
            GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2);

            GooglePoint GP3 = new GooglePoint();
            GP3.ID = "GP3";
            GP3.Latitude = 43.67689;
            GP3.Longitude = -79.43270;
            GP3.InfoHTML = "This is point 3";
            GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3);

            //Create Polylines between points GP1, GP2 and GP3.
            GooglePolyline PL1 = new GooglePolyline();
            PL1.ID = "PL1";
            //Give Hex code for line color
            PL1.ColorCode = "#0000FF";
            //Specify width for line
            PL1.Width = 5;

            PL1.Points.Add(GP1);
            PL1.Points.Add(GP2);
            PL1.Points.Add(GP3);

            //Add polyline to GoogleMap object
            GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);
        }
    }
Esempio n. 2
0
    public void Remove()
    {
        try
        {
            int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()) + 1;
            GooglePoint[] Gpoint = new GooglePoint[i + 1];
            GooglePolyline PL1 = new GooglePolyline();
            Array.Clear(Gpoint, 0, Gpoint.Length);
            PL1.Points.Clear();
            GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear();
            GoogleMapForASPNet1.GoogleMapObject.Points.Clear();
            GooglePoint Gp = new GooglePoint();

        }
        catch (Exception)
        {}
    }
Esempio n. 3
0
 public void Remove()
 {
     try
     {
         List<GooglePoint> Gp = new List<GooglePoint>();
         List<GooglePoint> Gp2 = new List<GooglePoint>();
         int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString());
         GooglePoint[] Gpoint = new GooglePoint[i];
         int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString());
         GooglePolyline PL1 = new GooglePolyline();
         GooglePoint[] Gpoint2 = new GooglePoint[i2];
         Array.Clear(Gpoint, 0, Gpoint.Length);
         Array.Clear(Gpoint2, 0, Gpoint.Length);
         Gp.Clear();
         Gp2.Clear();
         PL1.Points.Clear();
         GoogleMapForASPNet1.GoogleMapObject.Polylines.Clear();
         GoogleMapForASPNet1.GoogleMapObject.Points.Clear();
     }
     catch (Exception)
     {}
 }
Esempio n. 4
0
    private void BindMap(string GpxFile, string FileName)
    {
        lblJourny.Text = FileName;
        div_GpxMap.Visible = true;
        GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
        //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
        GoogleMapForASPNet1.GoogleMapObject.Width = "960px"; // You can also specify percentage(e.g. 80%) here
        GoogleMapForASPNet1.GoogleMapObject.Height = "450px";
        DataTable dat1 = new DataTable();
        GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 15;
        GooglePoint GP = new GooglePoint();
        dat1.Columns.Add("Lattitude", typeof(double));
        dat1.Columns.Add("Longitude", typeof(double));
        GooglePolyline PL1 = new GooglePolyline();
        PL1.Width = 5;
        PL1.ColorCode = "Green";

        DataTable _dt = new DataTable();
        _dt = LoadGPXWaypoints(GpxFile);
        if (_dt != null && _dt.Rows.Count > 0)
        {
            int i = Convert.ToInt32(_dt.Rows.Count);
            GooglePoint[] Gpoint = new GooglePoint[i + 1];
            List<string> City = new List<string>();
            bool frmCity = false;
            bool toCity = false;
            int objCont = 0;

            int pointsCount = 20;
            if (i < pointsCount)
            {
                pointsCount = i;
            }
            int pointsInterval = i / 20;

            int pointsPloatted = 1;

            for (int Count = 0; Count < _dt.Rows.Count; Count++)
            {
                if (Count % (pointsInterval + 1) == 0 && pointsPloatted < 19)
                {
                    string FromCity, ToCity = string.Empty;
                    double FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0;
                    try
                    {
                        FromCitylat = double.Parse(_dt.Rows[Count]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                        FromCitylon = double.Parse(_dt.Rows[Count]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                        ToCitylat = double.Parse(_dt.Rows[Count + 1]["lat"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                        ToCitylog = double.Parse(_dt.Rows[Count + 1]["lon"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                        if (FromCitylat != 0)
                        {
                            Gpoint[objCont] = new GooglePoint();
                            Gpoint[objCont].Latitude = FromCitylat;
                            Gpoint[objCont].Longitude = FromCitylon;
                            //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]);
                            dat1.NewRow();
                            dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude);
                            PL1.Points.Add(Gpoint[objCont]);
                            frmCity = true;
                            objCont++;
                        }
                        if (ToCitylat != 0)
                        {
                            Gpoint[objCont] = new GooglePoint();
                            Gpoint[objCont].Latitude = ToCitylat;
                            Gpoint[objCont].Longitude = ToCitylog;
                            //GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]);
                            dat1.NewRow();
                            dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude);
                            PL1.Points.Add(Gpoint[objCont]);
                            frmCity = false;
                            objCont++;
                        }
                    }
                    catch (Exception ex)
                    { }
                    GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);
                    pointsPloatted++;
                }
            }

            Double MinLattitude = Double.MaxValue;
            Double MinLongitude = Double.MaxValue;
            foreach (DataRow dr in dat1.Rows)
            {
                double Lattitude = dr.Field<double>("Lattitude");
                double Longitude = dr.Field<double>("Longitude");
                MinLattitude = Math.Min(MinLattitude, Lattitude);
                MinLongitude = Math.Min(MinLongitude, Longitude);
            }
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude);
        }
        else
        {
            GooglePoint GP0 = new GooglePoint();
            GP0.Latitude = 51.165691;
            GP0.Longitude = 10.451526;
            GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5;
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude);
        }
    }
Esempio n. 5
0
 public void Add(GooglePolyline pPolyline)
 {
     this.List.Add(pPolyline);
 }
Esempio n. 6
0
 public static GooglePolylines CloneMe(GooglePolylines prev)
 {
     GooglePolylines p = new GooglePolylines();
     for (int i = 0; i < prev.Count; i++)
     {
         GooglePolyline GPL = new GooglePolyline();
         GPL.ColorCode = prev[i].ColorCode;
         GPL.Geodesic = prev[i].Geodesic;
         GPL.ID = prev[i].ID;
         GPL.Points = GooglePoints.CloneMe(prev[i].Points);
         GPL.Width = prev[i].Width;
         p.Add(GPL);
     }
     return p;
 }
Esempio n. 7
0
    protected void Polylines_Add_From_gvDrawOnMap()
    {
        double golden_ratio = 0.618033988749895;
        Random random = new Random();
        double h = random.NextDouble();

        int value = 0;
        GooglePolyline polyline = new GooglePolyline();

        for (int i = 0; i < gvDrawOnMap.Rows.Count; i++)
        {
            if (value != Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text))
            {
                h += golden_ratio;
                h %= 1;
                value = Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text);
                polyline = new GooglePolyline();
                polyline.StrokeColor = ColorFromHSV(h, 0.99, 0.99);
                polyline.StrokeWeight = 4;
                LatLng latlong = new LatLng();
                latlong.Latitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[2].Text);
                latlong.Longitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[3].Text);
                polyline.Path.Add(latlong);
            }
            else
            {
                LatLng latlong = new LatLng();
                latlong.Latitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[2].Text);
                latlong.Longitude = Convert.ToDouble(gvDrawOnMap.Rows[i].Cells[3].Text);
                polyline.Path.Add(latlong);
            }

            if (i == (gvDrawOnMap.Rows.Count - 1))
                value = 0;
            else
            {
                if (Convert.ToInt16(gvDrawOnMap.Rows[i].Cells[1].Text) != Convert.ToInt16(gvDrawOnMap.Rows[i + 1].Cells[1].Text))
                    value = 0;
            }

            GoogleMap1.Polylines.Add(polyline);
        }
    }
Esempio n. 8
0
    protected void Polylines_Add()
    {
        GridPostaje.DataBind();
        gridPostajeLast.DataBind();

        Random random = new Random();
        int value = 0;
        GooglePolyline polyline = new GooglePolyline();

        for (int i = 0; i < GridPostaje.Rows.Count; i++)
        {
            if (value != Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text))
            {
                value = Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text);
                polyline = new GooglePolyline();
                polyline.StrokeColor = System.Drawing.Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
                polyline.StrokeWeight = 3;
                LatLng latlong = new LatLng();
                latlong.Latitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[2].Text);
                latlong.Longitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[3].Text);
                polyline.Path.Add(latlong);
            }
            else
            {
                LatLng latlong = new LatLng();
                latlong.Latitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[2].Text);
                latlong.Longitude = Convert.ToDouble(GridPostaje.Rows[i].Cells[3].Text);
                polyline.Path.Add(latlong);
            }

            if (i == (GridPostaje.Rows.Count - 1))
                value = 0;
            else
            {
                if (Convert.ToInt16(GridPostaje.Rows[i].Cells[1].Text) != Convert.ToInt16(GridPostaje.Rows[i + 1].Cells[1].Text))
                    value = 0;
            }

            GoogleMap1.Polylines.Add(polyline);
        }
    }
Esempio n. 9
0
    private void BindMap()
    {
        try
        {
            Remove();
            GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
            //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
            GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here
            GoogleMapForASPNet1.GoogleMapObject.Height = "350px";
            //Specify initial Zoom level.
            GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 2;
            //Specify Center Point for map. Map will be centered on this point.
            // Run time you can ava of lat or long
            List<GooglePoint> Gp = new List<GooglePoint>();
            GooglePoint min = new GooglePoint();
            int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString());
            GooglePoint[] Gpoint = new GooglePoint[i];
            GooglePolyline PL1 = new GooglePolyline();
            List<GooglePoint> Gp2 = new List<GooglePoint>();
            int i2 = Convert.ToInt32(grdStagePlan.Rows.Count.ToString());
            GooglePoint[] Gpoint2 = new GooglePoint[i2];
            GooglePoint min1 = new GooglePoint();
            double centerlat;
            double ceterlong;
            DataTable dat1=new DataTable();
            dat1.Columns.Add("Lattitude", typeof(double));
            dat1.Columns.Add("Longitude", typeof(double));
            DataTable dat2 = new DataTable();
            dat2.Columns.Add("Lattitude", typeof(double));
            dat2.Columns.Add("Longitude", typeof(double));
            PL1.ColorCode = "#0000FF";
            PL1.Width = 5;
            for (int Count = 0; Count <= grdStagePlan.Rows.Count; Count++)
            {
                string FromCity = string.Empty;
                string ToCity = string.Empty;
                 FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text;
                 ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text;
                if (FromCity != null)
                {
                    Gpoint[Count] = new GooglePoint();
                    Gp.Add(Gpoint[Count]);
                    Gpoint[Count].ID = "Gpoint[Count]";
                    string appId = "dj0yJmk9NUdkWVpoeGhPMHh1JmQ9WVdrOVZXRnFaa0poTm1zbWNHbzlNVEl6TURBek1UYzJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD04Nw--";
                    string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(FromCity), appId);
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                    try
                    {
                        using (WebResponse response = request.GetResponse())
                        {
                            using (DataSet ds = new DataSet())
                            {
                                try
                                {
                                    ds.ReadXml(response.GetResponseStream());
                                    Gpoint[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                                    Gpoint[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                                    GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[Count]);
                                    Gpoint[Count].InfoHTML=FromCity;
                                    Gpoint[Count].IconImage ="icons/sun.png";
                                    dat1.NewRow();
                                    dat1.Rows.Add(Gpoint[Count].Latitude, Gpoint[Count].Longitude);
                                    response.Close();
                                }
                                catch (Exception ex)
                                { }
                                finally
                                {
                                    ds.Dispose();
                                }

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                }

                if (ToCity != null)
                {
                    Gpoint2[Count] = new GooglePoint();
                    Gp2.Add(Gpoint[Count]);
                    Gpoint2[Count].ID = "Gpoint2[Count]";
                    string appId = "{ConsumerKey}";
                    string url = string.Format("http://where.yahooapis.com/geocode?location={0}&appid={1}", Server.UrlEncode(ToCity), appId);
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                    using (WebResponse response = request.GetResponse())
                    {
                        using (DataSet ds = new DataSet())
                        {
                            try
                            {
                                ds.ReadXml(response.GetResponseStream());
                                Gpoint2[Count].Latitude = double.Parse(ds.Tables["Result"].Rows[0]["Latitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                                Gpoint2[Count].Longitude = double.Parse(ds.Tables["Result"].Rows[0]["Longitude"].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                                GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint2[Count]);
                                Gpoint2[Count].InfoHTML =ToCity;
                                Gpoint[Count].IconImage = "icons/snow.png";
                                dat2.NewRow();
                                dat2.Rows.Add(Gpoint2[Count].Latitude, Gpoint2[Count].Longitude);
                                response.Close();
                            }
                            catch (Exception ex)
                            { }
                            finally
                            {
                                //ds.Clear();
                                ds.Dispose();
                            }

                        }
                    }
                }

                PL1.Points.Add(Gpoint[Count]);
                PL1.Points.Add(Gpoint2[Count]);
                GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);

            }

            //Plyline Draw
           // GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);
            //Google Map Certer
            Double MinLattitude = Double.MaxValue;
            Double MinLongitude = Double.MaxValue;
            foreach (DataRow dr in dat1.Rows)
            {
                double Lattitude = dr.Field<double>("Lattitude");
                double Longitude = dr.Field<double>("Longitude");
                MinLattitude = Math.Min(MinLattitude, Lattitude);
                MinLongitude = Math.Min(MinLongitude, Longitude);

            }

            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude);

        }
        catch (Exception ex)
        {
        }
    }
Esempio n. 10
0
    private void BindMap()
    {
        GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
        //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
        GoogleMapForASPNet1.GoogleMapObject.Width = "620px"; // You can also specify percentage(e.g. 80%) here
        GoogleMapForASPNet1.GoogleMapObject.Height = "350px";
        DataTable dat1 = new DataTable();
        GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5;
        GooglePoint GP = new GooglePoint();
        dat1.Columns.Add("Lattitude", typeof(double));
        dat1.Columns.Add("Longitude", typeof(double));
        GooglePolyline PL1 = new GooglePolyline();
        PL1.Width = 5;
        PL1.ColorCode = "Blue";
        int i = Convert.ToInt32(grdStagePlan.Rows.Count.ToString()) + 1;
        GooglePoint[] Gpoint = new GooglePoint[i + 1];
        List<string> City = new List<string>();
        bool frmCity = false;
        bool toCity = false;
        int objCont = 0;

        if (grdStagePlan.Rows.Count > 0)
        {
            for (int Count = 0; Count < grdStagePlan.Rows.Count; Count++)
            {
                string FromCity, ToCity = string.Empty;
                float FromCitylat, FromCitylon, ToCitylog, ToCitylat = 0;
                try
                {

                    FromCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblFromCity")).Text;
                    ToCity = ((Label)grdStagePlan.Rows[Count].FindControl("lblToCity")).Text;
                    FromCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[6].Text);
                    FromCitylon = float.Parse(grdStagePlan.Rows[Count].Cells[7].Text);
                    ToCitylat = float.Parse(grdStagePlan.Rows[Count].Cells[8].Text);
                    ToCitylog = float.Parse(grdStagePlan.Rows[Count].Cells[9].Text);
                    if (FromCity != null && !City.Contains(FromCity))
                    {

                        City.Add(FromCity);
                        Gpoint[objCont] = new GooglePoint();
                        Gpoint[objCont].InfoHTML = FromCity;
                        Gpoint[objCont].Latitude = FromCitylat;
                        Gpoint[objCont].Longitude = FromCitylon;
                        GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]);
                        dat1.NewRow();
                        dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude);
                        PL1.Points.Add(Gpoint[objCont]);
                        frmCity = true;
                        objCont++;
                    }
                    if (ToCity != null && !City.Contains(ToCity))
                    {

                        Gpoint[objCont] = new GooglePoint();
                        Gpoint[objCont].InfoHTML = ToCity;
                        Gpoint[objCont].Latitude = ToCitylat;
                        Gpoint[objCont].Longitude = ToCitylog;
                        GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[objCont]);
                        dat1.NewRow();
                        City.Add(ToCity);
                        dat1.Rows.Add(Gpoint[objCont].Latitude, Gpoint[objCont].Longitude);
                        PL1.Points.Add(Gpoint[objCont]);
                        frmCity = false;
                        objCont++;

                    }

                }
                catch (Exception ex)
                { }
                GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);

            }
            Double MinLattitude = Double.MaxValue;
            Double MinLongitude = Double.MaxValue;
            foreach (DataRow dr in dat1.Rows)
            {
                double Lattitude = dr.Field<double>("Lattitude");
                double Longitude = dr.Field<double>("Longitude");
                MinLattitude = Math.Min(MinLattitude, Lattitude);
                MinLongitude = Math.Min(MinLongitude, Longitude);
            }
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", MinLattitude, MinLongitude);
        }
        else
        {
            GooglePoint GP0 = new GooglePoint();
            GP0.Latitude = 51.165691;
            GP0.Longitude = 10.451526;
            GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5;
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", GP0.Latitude, GP0.Longitude);
        }
    }
Esempio n. 11
0
    private void BindMap(float Citylat, float Citylon, string CityName)
    {
        div_Map.Visible = true;
        GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
        //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
        GoogleMapForASPNet1.GoogleMapObject.Width = "500px"; // You can also specify percentage(e.g. 80%) here
        GoogleMapForASPNet1.GoogleMapObject.Height = "300px";
        DataTable dat1 = new DataTable();
        GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 5;
        GooglePoint GP = new GooglePoint();
        dat1.Columns.Add("Lattitude", typeof(double));
        dat1.Columns.Add("Longitude", typeof(double));
        GooglePolyline PL1 = new GooglePolyline();
        PL1.Width = 5;
        PL1.ColorCode = "Blue";

        GooglePoint[] Gpoint = new GooglePoint[1];
        List<string> City = new List<string>();

        Gpoint[0] = new GooglePoint();
        Gpoint[0].InfoHTML = CityName;
        Gpoint[0].Latitude = Citylat;
        Gpoint[0].Longitude = Citylon;
        GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gpoint[0]);

        GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", Citylat, Citylon);
    }
Esempio n. 12
0
    private void _BindMap(string startCity, string endCity, double percentage, double startcitylat, double startcitylong, double endCitylat, double endCitylong)
    {
        try
        {
            dlBlog.DataBind();
            GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
            //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
            GoogleMapForASPNet1.GoogleMapObject.Width = "700px"; // You can also specify percentage(e.g. 80%) here
            GoogleMapForASPNet1.GoogleMapObject.Height = "350px";
            //Specify initial Zoom level.
            GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 6;
            double centerlat;
            double ceterlong;
            GooglePoint GP1 = new GooglePoint();
            GP1.ID = "GP1";

            if (startCity != null)
            {

                double latitude = startcitylat;
                double longitude = startcitylong;
                GP1.Latitude = latitude;
                GP1.Longitude = longitude;
                GP1.InfoHTML = startCity;
                GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1);

            }

            GooglePoint GP2 = new GooglePoint();
            GP2.ID = "GP2";
            //Chemnitz
            if (endCity != null)
            {

                double latitude = endCitylat;
                double longitude = endCitylong;
                GP2.Latitude = latitude; //49.8776483;
                GP2.Longitude = longitude; // 8.6517617;
                GP2.InfoHTML = endCity;
                GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2);

            }

            GooglePoint Gp3 = new GooglePoint();
            // End City Lat & long Max Test
            if (GP1.Latitude < GP2.Latitude && GP1.Longitude < GP2.Longitude)
            {
                Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100);
                Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100);
            }
            else
            { //Start City Lat & Long Max
                if (GP1.Latitude > GP2.Latitude && GP1.Longitude > GP2.Longitude)
                {
                    Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100);
                    Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100);
                }
                else
                {  //Start city Lat max & long Mini  Test
                    if (GP1.Latitude > GP2.Latitude && GP1.Longitude < GP2.Longitude)
                    {
                        Gp3.Latitude = GP1.Latitude - (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100);
                        Gp3.Longitude = GP1.Longitude + (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100);
                    }
                    else
                    {  //start city lat Min & long Max  Test
                        if (GP1.Latitude < GP2.Latitude && GP1.Longitude > GP2.Longitude)
                        {
                            Gp3.Latitude = GP1.Latitude + (Math.Abs(GP2.Latitude - GP1.Latitude) * percentage / 100);
                            Gp3.Longitude = GP1.Longitude - (Math.Abs(GP2.Longitude - GP1.Longitude) * percentage / 100);
                        }
                    }
                }
            }

            Gp3.IconImage = "../_images/cycle.png";
            GoogleMapForASPNet1.GoogleMapObject.Points.Add(Gp3);
            if (GP1.Latitude > GP2.Latitude)
                centerlat = GP2.Latitude;
            else
                centerlat = GP1.Latitude;
            if (GP1.Longitude > GP2.Longitude)
                ceterlong = GP2.Longitude;
            else
                ceterlong = GP1.Longitude;

            //GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 146;
            GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", centerlat, ceterlong);
            GooglePolyline PL1 = new GooglePolyline();
            PL1.ID = "PL1";
            //Give Hex code for line color
            PL1.ColorCode = "#0000FF";
            //Specify width for line
            PL1.Width = 5;

            PL1.Points.Add(GP1);
            PL1.Points.Add(GP2);
            GoogleMapForASPNet1.GoogleMapObject.Polylines.Add(PL1);

        }
        catch (Exception ex)
        {
            Helper.Log(ex.Message, "Bind Google Map & Cycle ");
        }
    }