public void mapa(double lat, double lon, string _nombres, int _items_entregados, int _entregas)
        {
            GLatLng ubicacion = new GLatLng(lat, lon);

            GMap.setCenter(ubicacion, 15);

            //Establecemos alto y ancho en px
            GMap.Height = 600;
            GMap.Width  = 940;

            //Adiciona el control de la parte izq superior (moverse, ampliar y reducir)
            GMap.Add(new GControl(GControl.preBuilt.LargeMapControl));

            //GControl.preBuilt.MapTypeControl: permite elegir un tipo de mapa y otro.
            GMap.Add(new GControl(GControl.preBuilt.MapTypeControl));

            //Con esto podemos definir el icono que se mostrara en la ubicacion
            //#region Crear Icono
            GIcon iconPropio = new GIcon();

            iconPropio.image            = "../Images/marcadornestle1.png";
            iconPropio.shadow           = "../Images/marcadorsombranestle1.png";;
            iconPropio.iconSize         = new GSize(32, 32);
            iconPropio.shadowSize       = new GSize(29, 16);
            iconPropio.iconAnchor       = new GPoint(10, 18);
            iconPropio.infoWindowAnchor = new GPoint(10, 9);
            //#endregion



            //Pone la marca de gota de agua con el nombre de la ubicacion
            GMarker marker    = new GMarker(ubicacion, iconPropio);
            string  strMarker = "<div style='width: 200px; border-radius: 35px; ; height: 150px'><b>" +
                                "<span style='color:#ff7e00'>Establecimiento: </span>" + _nombres + "</b><br>" +
                                " Items Entregados: " + _items_entregados + " <br /> Cantidad de Entregas: " + _entregas + "<br />" + "" + "<br /><br><br></div>";

            /*string strMarker = "<div style='width: 250px; height: 185px'><b>" +
             *  "<span style='color:#ff7e00'>es</span>ASP.NET</b><br>" +
             *  " C/ C/ Nombre de Calle, No X <br /> 28031 Madrid, España <br />" +
             *  "Tel: +34 902 00 00 00 <br />Fax: +34 91 000 00 00<br />" +
             *  "Web: <a href='http://www.esASP.net/' class='txtBKM' >www.esASP.net</a>" +
             *  "<br />Email: <a href='mailto:[email protected]' class='txtBKM'>" +
             *  "[email protected]</a><br><br></div>";   */
            GInfoWindow window = new GInfoWindow(marker, strMarker, false, GListener.Event.mouseover);

            GMap.Add(window);

            GMap.enableHookMouseWheelToZoom = true;

            //Tipo de mapa a mostrar
            //GMap.mapType  = GMapType.GTypes.Normal;
            GMapType.GTypes maptype = GMapType.GTypes.Normal;

            GLatLng latlong = new GLatLng(-0.185631, -78.484490);

            GMap.setCenter(latlong, 12, maptype);

            //Moverse con el cursor del teclado
            GMap.enableGKeyboardHandler = true;
        }
        private void LoadGMap(string latitude, string longitude, string companyName, string address, string imageName)
        {
            PinIcon     p;
            GMarker     gm;
            GInfoWindow win;

            GLatLng mainLocation = new GLatLng(DBConvert.ParseDouble(latitude), DBConvert.ParseDouble(longitude));

            GMapType.GTypes maptype = GMapType.GTypes.Normal;
            GMap1.setCenter(mainLocation, 15, maptype);
            GMap1.enableHookMouseWheelToZoom = true;

            GMapUIOptions options = new GMapUIOptions();

            options.maptypes_hybrid  = true;
            options.maptypes_normal  = true;
            options.zoom_scrollwheel = true;
            GMap1.Add(new GMapUI(options));

            //GMarker marker = new GMarker(mainLocation);
            GIcon icon = new GIcon();

            icon.markerIconOptions = new MarkerIconOptions(50, 50, Color.Blue);
            p   = new PinIcon(PinIcons.home, Color.Cyan);
            gm  = new GMarker(mainLocation, new GMarkerOptions(new GIcon(p.ToString(), p.Shadow())));
            win = new GInfoWindow(gm, HtmlIconMap(imageName, companyName, address), false, GListener.Event.mouseover);

            GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));
            GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));
            GMap1.Add(win);
        }
示例#3
0
        private void AddMarkers()
        {
            List<Tree> trees = bl.GetAllTrees("School101", "School101");
            foreach (var tree in trees)
            {
                double lat;
                if (!double.TryParse(tree.Latitude, out lat))
                    continue;
                double lng;
                if (!double.TryParse(tree.Longitude, out lng))
                    continue;

                var latlng = new GLatLng(lat, lng);
                var icon = new GIcon(Helper.GetTreeIcon(tree.TreeType));
                icon.iconSize = new GSize(10, 10);
                icon.iconAnchor = new GPoint(7, 7);
                var options = new GMarkerOptions(icon, true, Helper.GetTreeType(tree.TreeType) + " " + tree.ID);
                GMarker marker = new GMarker(latlng, options);
                map.Add(marker);

                string popupContent = string.Format(@"
                    <h2>{0} {1}</h2>
                    <p>Координати: {2}, {3}<p/>
                    <p>Точност: {4}<p/>
                    <p>Добавено на: {5}<p/>
                    ", Helper.GetTreeType(tree.TreeType), tree.ID, tree.Latitude, tree.Latitude, tree.Accuracy, tree.DateAdded);
                GListener listener = new GListener(marker.ID, GListener.Event.click, string.Format(@"
                    function () {{
                        var w = new google.maps.InfoWindow();
                        w.setContent('{0}');
                        w.open({1}, {2});
                    }}", popupContent, map.GMap_Id, marker.ID));
                map.Add(listener);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);

            GMap1.setCenter(latLng, 4);

            GIcon icon = new GIcon();

            icon.markerIconOptions = new MarkerIconOptions(50, 50, Color.Blue);
            GMarker     marker = new GMarker(latLng, icon);
            GInfoWindow window = new GInfoWindow(marker, "You can use the Map Icon Maker as any other marker");

            GMap1.Add(window);

            GIcon icon2 = new GIcon();

            icon2.labeledMarkerIconOptions = new LabeledMarkerIconOptions(Color.Gold, Color.White, "A", Color.Green);
            GMarker     marker2 = new GMarker(latLng + new GLatLng(3, 3), icon2);
            GInfoWindow window2 = new GInfoWindow(marker2, "You can use the Map Icon Maker as any other marker");

            GMap1.Add(window2);

            GIcon icon3 = new GIcon();

            icon3.flatIconOptions = new FlatIconOptions(25, 25, Color.Red, Color.Black, "B", Color.White, 15,
                                                        FlatIconOptions.flatIconShapeEnum.roundedrect);
            GMarker     marker3 = new GMarker(latLng + new GLatLng(-3, -3), icon3);
            GInfoWindow window3 = new GInfoWindow(marker3, "You can use the Map Icon Maker as any other marker");

            GMap1.Add(window3);
        }
        protected string GMap1_Click(object s, GAjaxServerEventArgs e)
        {
            string respuesta = string.Empty;
            Punto  pun       = new Punto();

            pun.longitud = e.point.lng.ToString();
            pun.latitud  = e.point.lat.ToString();
            listaPunto.Add(pun);

            Session["listaPunto"] = listaPunto;

            if (DropDownList1.SelectedValue == "Punto")
            {
                GIcon icon = new GIcon();
                icon.image  = "https://www.google.es/maps/vt/icon/name=icons/spotlight/spotlight-poi-medium.png&scale=2?scale=1";
                icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                GMarkerOptions mOpts = new GMarkerOptions();
                mOpts.clickable = true;
                mOpts.icon      = icon;
                GMarker     marker = new GMarker(e.point, mOpts);
                GInfoWindow window = new GInfoWindow(marker,
                                                     string.Format(
                                                         @"<b>Longitud y Latitud del Punto</b><br />SW = {0}<br/>NE = {1} <br /> LatLogn{2}",
                                                         e.bounds.getSouthWest(),
                                                         e.bounds.getNorthEast(),
                                                         e.point
                                                         ),
                                                     true);
                txtNombre.Focus();
                txtLatitud.Text  = e.point.lat.ToString();
                txtLongitud.Text = e.point.lng.ToString();
                txtNombre.Text   = string.Empty;

                btnInsertar.Enabled = true;
                btnLimpiar.Enabled  = true;
                respuesta           = window.ToString(e.map);
            }
            if (DropDownList1.SelectedValue == "Linea" && listaPunto.Count > 1)
            {
                GMarker     marker = new GMarker(e.point);
                GInfoWindow window = new GInfoWindow(marker,
                                                     string.Format(
                                                         @"<b>Longitud y Latitud del Punto</b><br />SW = {0}<br/>NE = {1} <br /> LatLogn{2}",
                                                         e.bounds.getSouthWest(),
                                                         e.bounds.getNorthEast(),
                                                         e.point
                                                         ),
                                                     true);
                respuesta = window.ToString(e.map);
            }
            return(respuesta);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);

            GMap1.setCenter(latLng);

            GIcon icon = new GIcon();

            icon.image            = "http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greencirclemarker.png";
            icon.iconSize         = new GSize(32, 32);
            icon.iconAnchor       = new GPoint(16, 16);
            icon.infoWindowAnchor = new GPoint(25, 7);



            StyledIconOptions iconOptions1 = new StyledIconOptions()
            {
                Text      = "Hi",
                Color     = Color.Blue,
                Fore      = Color.Red,
                StarColor = Color.Green
            };

            StyledIcon icon1 = new StyledIcon(StyledIconType.Marker, iconOptions1);

            StyledMarker styledMarker1 = new StyledMarker(latLng, icon1);

            StyledIconOptions iconOptions2 = new StyledIconOptions()
            {
                Text  = "Hi, I'm a bubble!",
                Color = Color.Orange,
                Fore  = Color.PaleGreen,
            };

            StyledIcon icon2 = new StyledIcon(StyledIconType.Bubble, iconOptions2);

            StyledMarker styledMarker2 = new StyledMarker(latLng + new GLatLng(1.0, 1.0), icon2);

            GInfoWindow window1 = new GInfoWindow(styledMarker1, "You can user StyledMarker as any other marker!");
            GInfoWindow window2 = new GInfoWindow(styledMarker2, "You can user StyledMarker as any other marker!");

            GMap1.Add(window1);
            GMap1.Add(window2);
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);
            GMap1.setCenter(latLng);

            GIcon icon = new GIcon();
            icon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greencirclemarker.png";
            icon.iconSize = new GSize(32, 32);
            icon.iconAnchor = new GPoint(16, 16);
            icon.infoWindowAnchor = new GPoint(25, 7);

            LabeledMarker labeledMarker = new LabeledMarker(latLng);
            labeledMarker.options.labelText = "S";
            labeledMarker.options.labelOffset = new GSize(-4, -7);
            labeledMarker.options.icon = icon;

            GInfoWindow window = new GInfoWindow(labeledMarker, "You can use the Labeled Marker as any other marker");
            GMap1.Add(window);
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Habilitando o zoom no mapa
            GoogleMaps.enableHookMouseWheelToZoom = true;

            // Definir o tipo do mapa
            // Satellite, Hybrid, Physical, Normal
            GoogleMaps.mapType = GMapType.GTypes.Normal;

            // Define a Latitude e Logitude inicial do Mapa
            // Como moro em Brasília, coloquei o Congresso Nacional
            GLatLng latitudeLongitude = new GLatLng(-25.366085, -49.220698);

            // Definimos onde será o ponto inicial do nosso mapa
            // e o numero é o ZOOM inicial
            GoogleMaps.setCenter(latitudeLongitude, 17);

            GIcon icon = new GIcon();

            icon.image            = "/img/3gsaticon.png";
            icon.iconSize         = new GSize(32, 32);
            icon.shadowSize       = new GSize(22, 20);
            icon.iconAnchor       = new GPoint(6, 20);
            icon.infoWindowAnchor = new GPoint(5, 1);

            GMarkerOptions mOpts = new GMarkerOptions();

            mOpts.icon = icon;

            // Acionando os controles
            GControl overview   = new GControl(GControl.preBuilt.GOverviewMapControl);
            GControl MapControl = new GControl(GControl.preBuilt.LargeMapControl3D);

            GoogleMaps.addControl(overview);
            GoogleMaps.addControl(MapControl);

            GMarker     marker = new GMarker(latitudeLongitude, mOpts);
            GInfoWindow window = new GInfoWindow(marker, "<center><b>Teste 3GSat<BR>Teste linha<BR>" + latitudeLongitude + "</b></center>");

            GoogleMaps.addGMarker(marker);
            GoogleMaps.addInfoWindow(window);
        }
示例#9
0
        public GMarkerOptions GetMarkerOpts()
        {
            GIcon icon = new GIcon();

            //Create icon images for markers based on site type
            icon.image  = "images/icons/8.png";
            icon.shadow = "http://wdr.water.usgs.gov/adrgmap/images/icons16x16/sw_onlys.png";

            icon.iconSize         = new GSize(16, 16);
            icon.shadowSize       = new GSize(26, 16);
            icon.iconAnchor       = new GPoint(8, 8);
            icon.infoWindowAnchor = new GPoint(8, 0);

            GMarkerOptions mOpts = new GMarkerOptions();

            mOpts.clickable = true;
            mOpts.icon      = icon;

            return(mOpts);
        }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(41, -3.2);

            GMap1.setCenter(latlng, 5);

            GIcon icon = new GIcon();
            icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
            icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
            icon.iconSize = new GSize(12, 20);
            icon.shadowSize = new GSize(22, 20);
            icon.iconAnchor = new GPoint(6, 20);
            icon.infoWindowAnchor = new GPoint(5, 1);

            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.clickable = false;
            mOpts.icon = icon;

            GMarker marker = new GMarker(latlng, mOpts);
            GMap1.Add(marker);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);
            GMap1.setCenter(latLng);

            GIcon icon = new GIcon();
            icon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greencirclemarker.png";
            icon.iconSize = new GSize(32, 32);
            icon.iconAnchor = new GPoint(16, 16);
            icon.infoWindowAnchor = new GPoint(25, 7);

            StyledIconOptions iconOptions1 = new StyledIconOptions()
                                                {
                                                    Text = "Hi",
                                                    Color = Color.Blue,
                                                    Fore = Color.Red,
                                                    StarColor = Color.Green
                                                };

            StyledIcon icon1 = new StyledIcon(StyledIconType.Marker, iconOptions1);

            StyledMarker styledMarker1 = new StyledMarker(latLng, icon1);

            StyledIconOptions iconOptions2 = new StyledIconOptions()
                                                {
                                                    Text = "Hi, I'm a bubble!",
                                                    Color = Color.Orange,
                                                    Fore = Color.PaleGreen,
                                                };

            StyledIcon icon2 = new StyledIcon(StyledIconType.Bubble, iconOptions2);

            StyledMarker styledMarker2 = new StyledMarker(latLng + new GLatLng(1.0, 1.0), icon2);

            GInfoWindow window1 = new GInfoWindow(styledMarker1, "You can user StyledMarker as any other marker!");
            GInfoWindow window2 = new GInfoWindow(styledMarker2, "You can user StyledMarker as any other marker!");

            GMap1.Add(window1);
            GMap1.Add(window2);
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);

            GMap1.setCenter(latLng);

            GIcon icon = new GIcon();

            icon.image            = "http://gmaps-samples.googlecode.com/svn/trunk/markers/circular/greencirclemarker.png";
            icon.iconSize         = new GSize(32, 32);
            icon.iconAnchor       = new GPoint(16, 16);
            icon.infoWindowAnchor = new GPoint(25, 7);

            LabeledMarker labeledMarker = new LabeledMarker(latLng);

            labeledMarker.options.labelText   = "S";
            labeledMarker.options.labelOffset = new GSize(-4, -7);
            labeledMarker.options.icon        = icon;

            GInfoWindow window = new GInfoWindow(labeledMarker, "You can use the Labeled Marker as any other marker");

            GMap1.Add(window);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(41, -3.2);

            GMap1.setCenter(latlng, 5);

            GIcon icon = new GIcon();

            icon.image            = "http://labs.google.com/ridefinder/images/mm_20_red.png";
            icon.shadow           = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
            icon.iconSize         = new GSize(12, 20);
            icon.shadowSize       = new GSize(22, 20);
            icon.iconAnchor       = new GPoint(6, 20);
            icon.infoWindowAnchor = new GPoint(5, 1);

            GMarkerOptions mOpts = new GMarkerOptions();

            mOpts.clickable = false;
            mOpts.icon      = icon;

            GMarker marker = new GMarker(latlng, mOpts);

            GMap1.Add(marker);
        }
示例#14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latLng = new GLatLng(50, 10);
            GMap1.setCenter(latLng, 4);

            GIcon icon = new GIcon();
            icon.markerIconOptions = new MarkerIconOptions(50, 50, Color.Blue);
            GMarker marker = new GMarker(latLng, icon);
            GInfoWindow window = new GInfoWindow(marker, "You can use the Map Icon Maker as any other marker");
            GMap1.Add(window);

            GIcon icon2 = new GIcon();
            icon2.labeledMarkerIconOptions = new LabeledMarkerIconOptions(Color.Gold, Color.White, "A", Color.Green);
            GMarker marker2 = new GMarker(latLng + new GLatLng(3, 3), icon2);
            GInfoWindow window2 = new GInfoWindow(marker2, "You can use the Map Icon Maker as any other marker");
            GMap1.Add(window2);

            GIcon icon3 = new GIcon();
            icon3.flatIconOptions = new FlatIconOptions(25, 25, Color.Red, Color.Black, "B", Color.White, 15,
                                                        FlatIconOptions.flatIconShapeEnum.roundedrect);
            GMarker marker3 = new GMarker(latLng + new GLatLng(-3, -3), icon3);
            GInfoWindow window3 = new GInfoWindow(marker3, "You can use the Map Icon Maker as any other marker");
            GMap1.Add(window3);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["longitude"] == null || Session["latitude"] == null)
        {
            if (Request.Form["txtLng"] == null || Request.Form["txtLat"] == null)
            {
                Response.Redirect("~/requestLocation.aspx");
            }
            else
            {
                Session["longitude"] = Request.Form["txtLng"];
                Session["latitude"] = Request.Form["txtLat"];
            }
        }

        double myX = 0;
        double myY = 0;

        try
        {
            myX = Double.Parse(Session["longitude"].ToString(), System.Globalization.CultureInfo.GetCultureInfo("en-us"));
            myY = Double.Parse(Session["latitude"].ToString(), System.Globalization.CultureInfo.GetCultureInfo("en-us"));
        }
        catch (Exception)
        {
            Response.Redirect("~/overview.aspx");
        }

        GLatLng p1 = new GLatLng();

        p1.lat = myY;
        p1.lng = myX;

        GMap1.setCenter(p1, 15);

        GMap1.addGMapUI(new GMapUI());

        GMap1.Height = 400;
        GMap1.Width = 800;

        GMapUIOptions options = new GMapUIOptions();
        options.maptypes_hybrid = true;
        options.keyboard = true;
        options.maptypes_physical = true;
        options.zoom_scrollwheel = true;

        GIcon icoon = new GIcon();
        icoon.image = "img/userLocation.png";
        icoon.iconSize = new GSize(32, 32);
        icoon.shadowSize = new GSize(60, 32);

        GMarker marker1 = new GMarker(p1, icoon);
        GMap1.addGMarker(marker1);

        GInfoWindow userWindow = new GInfoWindow();
        userWindow.gMarker = marker1;
        userWindow.html = "<h3>U bevindt zich hier</h3>";
        GMap1.addInfoWindow(userWindow);

        Api api = new Api();
        XDocument doc = api.getApiData("stations/", "NL", "xml");

        foreach (XElement d in doc.Descendants("stations").Descendants("station"))
        {
            string lat = d.Attribute("locationY").Value;
            string lng = d.Attribute("locationX").Value;

            double y = Double.Parse(lat, System.Globalization.CultureInfo.GetCultureInfo("en-us"));
            double x = Double.Parse(lng, System.Globalization.CultureInfo.GetCultureInfo("en-us"));

            double distance = GetDistanceBetweenPoints(myX, myY, x, y);

            Station s = new Station(d.Value.ToString(), y, x, distance);
            stations.Add(s);
        }

        var stationsQueryAble = stations.AsQueryable();
        stationsQueryAble = stationsQueryAble.OrderBy(stat => stat.afstandTotHuidigeLocatie);

        stations = stationsQueryAble.ToList();

        for (int i = 0; i < 5; i++)
        {
            GLatLng p2 = new GLatLng();
            p2.lat = stations[i].locY;
            p2.lng = stations[i].locX;
            GMarker marker = new GMarker(p2);
            GMap1.addGMarker(marker);

            GInfoWindow win1 = new GInfoWindow();

            win1.gMarker = marker;
            win1.html = "<h3><a href='overview.aspx?station=" + stations[i].stationNaam + "'>" + stations[i].stationNaam + " station</a></h3><p>afstand: " + Math.Round(stations[i].afstandTotHuidigeLocatie, 2) + "km</p>";
            GMap1.addInfoWindow(win1);
        }
    }
示例#16
0
    private void BindGmapData()
    {
        var            user = _userBL.GetUser(HttpContext.Current.User.Identity.Name);
        List <t_Sites> sites;

        if (user.Role == "consumer")
        {
            sites = _siteBL.GetSitesForMapByConsumerID(user.ConsumerId).ToList();
        }
        else if (user.Role == "staff")
        {
            sites = _siteBL.GetSitesForMapByStaffId(user.StaffId).ToList();
        }
        else
        {
            sites = null;
        }

        //var sites = _siteBL.GetSitesForMap().ToList();

        if (sites.Count == 0)
        {
            GMap1.setCenter(new GLatLng(16.109833, 107.201294), 6);
            return;
        }
        List <string> groups = (from s in sites
                                select s.DisplayGroup).Distinct().ToList();

        if (!IsPostBack)
        {
            GMap1.GZoom = (int)sites.Select(s => s.Zoom).Min();

            int i = 0;
            foreach (string g in groups)
            {
                Telerik.Web.UI.RadTreeNode parent = new Telerik.Web.UI.RadTreeNode(g);
                trvSites.Nodes.Add(parent);
                var gSites = (from s1 in sites
                              where s1.DisplayGroup == g
                              select s1).ToList();

                foreach (t_Sites gS in gSites)
                {
                    Telerik.Web.UI.RadTreeNode child = new Telerik.Web.UI.RadTreeNode(gS.Location, gS.SiteAliasName);
                    child.NavigateUrl = String.Format("javascript:open_Window({0});", i.ToString());
                    parent.Nodes.Add(child);
                    i++;
                }
            }
            trvSites.ExpandAllNodes();
        }
        GLatLngBounds gLatLngBounds = new GLatLngBounds();

        double   forwardIndex = 0;
        double   reveseIndex  = 0;
        DateTime?lastForwardIndexTimeStamp = null;
        DateTime?lastReverseIndexTimeStamp = null;
        double?  index          = 0;
        DateTime?indexTimeStamp = null;

        GIcon icon = new GIcon();

        icon.image            = System.Configuration.ConfigurationManager.AppSettings["gMarkerIcon"];
        icon.iconSize         = new GSize(20, 20);
        icon.shadowSize       = new GSize(20, 20);
        icon.iconAnchor       = new GPoint(6, 20);
        icon.infoWindowAnchor = new GPoint(5, 1);

        GIcon icon_alrm = new GIcon();

        icon_alrm.image            = System.Configuration.ConfigurationManager.AppSettings["gMarkerIconError"];
        icon_alrm.iconSize         = new GSize(20, 20);
        icon_alrm.shadowSize       = new GSize(20, 20);
        icon_alrm.iconAnchor       = new GPoint(6, 20);
        icon_alrm.infoWindowAnchor = new GPoint(5, 1);

        GMap1.resetCustomInsideJS();
        GMap1.resetCustomJS();
        GMap1.resetInfoWindows();
        GMap1.resetMarkers();

        //Alarm display
        List <string>   listSiteAlarm = new List <string>();
        OleDbConnection aCnn          = new OleDbConnection("");

        aCnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\PMAC\PMACSITE.MDB";
        try
        {
            aCnn.Open();
            OleDbCommand    aCmd = new OleDbCommand("SELECT [Id] FROM [ALARMLOG] WHERE Priority LIKE 'H' OR Priority LIKE 'L' GROUP BY [Id]", aCnn);
            OleDbDataReader aRdr = aCmd.ExecuteReader();
            while (aRdr.Read())
            {
                listSiteAlarm.Add(aRdr[0].ToString());
            }
            aCnn.Close();
            aCnn.Dispose();
        }
        catch (Exception ex)
        {
            throw ex;
        }

        StringBuilder sb = new StringBuilder();

        sb.Append("markers = [];");
        sb.Append("lablelMarkers = [];");
        sb.Append("function add_Window()");
        sb.Append("{");
        string formatedAliasName;

        bool flag = false;

        foreach (string g in groups)
        {
            var gSites = (from s1 in sites
                          where s1.DisplayGroup == g
                          select s1).ToList();

            foreach (var s in gSites)
            {
                formatedAliasName = Clean(s.SiteAliasName);
                //formatedAliasName = s.SiteAliasName.Replace(' ', '_').Replace('.', '_').Replace('-','_').Replace('+','_');
                var channels = _channelConfigurationBL.GetChannelConfigurationsByLoggerID(s.LoggerId);
                forwardIndex = 0;
                reveseIndex  = 0;
                foreach (var c in channels)
                {
                    if (c.ForwardFlow == true)
                    {
                        forwardIndex = c.LastIndex ?? 0;
                        lastForwardIndexTimeStamp = c.IndexTimeStamp;
                    }
                    else if (c.ReverseFlow == true)
                    {
                        reveseIndex = c.LastIndex ?? 0;
                        lastReverseIndexTimeStamp = c.IndexTimeStamp;
                    }
                }
                index          = forwardIndex - reveseIndex;
                indexTimeStamp = lastForwardIndexTimeStamp ?? lastReverseIndexTimeStamp;

                string label = "";
                label += "<div id='l_" + formatedAliasName + "' >";
                label += "<div class='lblSiteName'>" + formatedAliasName + "</div>";
                label += "<table border='0' cellpadding='3' cellspacing='0'>";

                string html = "";

                html += "<div class=\"text\">"
                        + "Alias name"
                        + ": "
                        + s.SiteAliasName
                        + "</div>";
                html += "<div class=\"text\">"
                        + "Vị trí"
                        + ": "
                        + s.Location
                        + "</div>";
                html += "<div class=\"text\">"
                        + "Cỡ ống"
                        + ": "
                        + s.PipeSize
                        + "</div>";
                html += "<div class=\"text\">"
                        + "Chỉ số"
                        + ": "
                        + string.Format("{0:0.0}", index) + " (" + (indexTimeStamp != null ? ((DateTime)indexTimeStamp).ToString("dd/MM/yyyy HH:mm") : "") + ")"
                        + "</div>";
                html += "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" style=\"width:auto;height:auto;\">";
                html += "<tr><td class=\"tblHeader\">"
                        + "Kênh"
                        + "</td><td class=\"tblHeader\">"
                        + "Mô tả"
                        + "</td><td class=\"tblHeader\">"
                        + "Ngày giờ"
                        + "</td><td class=\"tblHeader\">"
                        + "Giá trị"
                        + "</td><td class=\"tblHeader\">"
                        + "Đơn vị"
                        + "</td></tr>";

                flag = false;

                foreach (var c in channels)
                {
                    html += "<tr><td class=\"cellCenter\">"
                            + c.ChannelId
                            + "</td><td class=\"cellCenter\">"
                            + c.ChannelName
                            + "</td><td class=\"cellCenter imp\">"
                            + (c.TimeStamp == null ? "NO DATA" : ((DateTime)c.TimeStamp).ToString("dd/MM/yyyy HH:mm"))
                            + "</td><td class=\"cellRight imp\">"
                            + string.Format(culture, "{0:0.0}", c.LastValue)
                            + "</td><td class=\"cellLeft\">"
                            + c.Unit
                            + "</td></tr>";

                    if ((c.Pressure2 == true && c.Pressure1 == false && flag == false) || (c.Pressure2 == false && c.Pressure1 == true && flag == false))
                    {
                        label += "<tr><td class='cellCenterLbl'>"
                                 + (c.LastValue == null ? "NO DATA" : string.Format(culture, "{0:0.0}", c.LastValue))
                                 //+ "</td><td class='cellCenterLbl'>"
                                 //+ c.Unit
                                 + "</td></tr>";

                        flag = true;
                    }
                }

                html  += "</table>";
                label += "</table></div>";

                GMarkerOptions markerOptions = new GMarkerOptions();
                if (listSiteAlarm.Contains(s.LoggerId) || s.t_Logger_Configurations.Alarm == true)
                {
                    markerOptions.icon = icon_alrm;
                }
                else
                {
                    markerOptions.icon = icon;
                }
                markerOptions.Animation = GMarkerOptions.AnimationType.Bounce;

                GLatLng loc    = new GLatLng((double)s.Latitude, (double)s.Longitude);
                GMarker marker = new GMarker(loc, markerOptions);
                marker.ID = "m_" + formatedAliasName;
                GInfoWindow infoWindow = new GInfoWindow(marker, html);
                sb.Append(infoWindow.ToString(GMap1.GMap_Id));

                sb.AppendFormat("var {0} = new MarkerWithLabel(", "l_m_" + formatedAliasName);
                sb.Append("{");
                sb.AppendFormat(culture, "position: new google.maps.LatLng({0}, {1}),", (double)s.Latitude, (double)s.Longitude);
                sb.Append("draggable: false,");
                sb.Append("raiseOnDrag: false,");
                sb.AppendFormat("map: {0},", GMap1.GMap_Id);
                sb.AppendFormat("labelContent: \"{0}\",", label);
                sb.Append("labelAnchor: new google.maps.Point(15, 0),");
                sb.Append("icon: {}");
                sb.Append("});");

                sb.AppendFormat("{0}.setVisible(display);", "l_m_" + formatedAliasName);

                sb.AppendFormat("google.maps.event.addListener({0}, 'click', function (e) ", "l_m_" + formatedAliasName);
                sb.Append("{");
                sb.AppendFormat("google.maps.event.trigger({0}, 'click')", marker.ID);
                sb.Append("});");

                sb.AppendFormat("markers.push({0});", marker.ID);
                sb.AppendFormat("lablelMarkers.push({0});", "l_m_" + formatedAliasName);

                gLatLngBounds.extend(loc);
            }
        }

        if (!IsPostBack)
        {
            //fitBounds
            sb.Append("var myBounds = new google.maps.LatLngBounds(); ");
            sb.AppendFormat("var ne = new google.maps.LatLng({0},{1});", gLatLngBounds.ne.lat.ToString(), gLatLngBounds.ne.lng.ToString());
            sb.AppendFormat("var sw = new google.maps.LatLng({0},{1});", gLatLngBounds.sw.lat.ToString(), gLatLngBounds.sw.lng.ToString());
            sb.Append("myBounds.extend(ne);myBounds.extend(sw);");
            sb.AppendFormat("{0}.fitBounds(myBounds);", GMap1.GMap_Id);
        }
        //Center on page reload event
        sb.AppendFormat("google.maps.event.addListener({0}, 'center_changed', function()", GMap1.GMap_Id);
        sb.Append("{");
        sb.AppendFormat("center={0}.getCenter();", GMap1.GMap_Id);
        sb.Append("});");
        sb.AppendFormat("{0}.setCenter(center);", GMap1.GMap_Id);

        //	create the ContextMenu object
        sb.AppendFormat("var contextMenu = new ContextMenu({0}, contextMenuOptions);", GMap1.GMap_Id);

        //	display the ContextMenu on a Map right click
        sb.AppendFormat("google.maps.event.addListener({0}, 'rightclick', function (mouseEvent)", GMap1.GMap_Id);
        sb.Append("{contextMenu.show(mouseEvent.latLng);});");

        sb.Append("google.maps.event.addListener(contextMenu, 'menu_item_selected', function (latLng, eventName) {");
        sb.Append("switch (eventName) {");
        sb.Append("case 'hide_click':");
        sb.Append("for (var i = 0; i < lablelMarkers.length; i++) {");
        sb.Append("lablelMarkers[i].setVisible(false);");
        sb.Append("display=false;");
        sb.Append("}");
        sb.Append("break;");
        sb.Append("case 'show_click':");
        sb.Append("for (var i = 0; i < lablelMarkers.length; i++) {");
        sb.Append("lablelMarkers[i].setVisible(true);");
        sb.Append("display=true;");
        sb.Append("}");
        sb.Append("break;");
        sb.Append("}");
        sb.Append("});");

        sb.Append("}");


        GMap1.Add(sb.ToString());
        GMap1.Add("add_Window();", true);
    }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MarkerManager mManager = new MarkerManager();
            double lat = 0.0;
            double longi = 0.0;

            //reset listeners, necessary for marker listener to work between postback
            GMap1.resetListeners();

            //Create default marker
            GIcon icon = new GIcon();
            icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
            icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
            icon.iconSize = new GSize(20, 28);
            icon.shadowSize = new GSize(30, 28);
            icon.iconAnchor = new GPoint(10, 18);
            icon.infoWindowAnchor = new GPoint(5, 1);

            GMap1.mapType = GMapType.GTypes.Hybrid;

            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.clickable = false;
            mOpts.icon = icon;

            //GMap1.GZoom = 3; //set zoom level
            GMap1.Key = ConfigurationSettings.AppSettings["GoogleMapKey"];
            GMap1.enableDragging = true;
            GMap1.enableGoogleBar = false;
            GMap1.Language = "en";
            GMap1.BackColor = Color.White;
            //GMap1.enableHookMouseWheelToZoom = true;
            GMap1.enableGKeyboardHandler = true;

            //Add built-in control for selecting map type
            GMap1.addControl(new GControl(GControl.preBuilt.MapTypeControl));

            //Add built-in control for zoom and pan
            //GMap1.addControl(new GControl(GControl.preBuilt.SmallZoomControl3D));
            GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl3D));

            //Custom cursor
            GCustomCursor customCursor = new GCustomCursor(cursor.crosshair, cursor.text);
            GMap1.addCustomCursor(customCursor);

            //Mark centre with a "+"
            GControl control = new GControl(GControl.extraBuilt.MarkCenter);

            //Adds a textbox which gives the coordinates of the last click
            GMap1.addControl(new GControl(GControl.extraBuilt.TextualOnClickCoordinatesControl,
                                new GControlPosition(GControlPosition.position.Bottom_Right)));

            //Add all stops to GMAP
            var stops =
                from s in JUTCLinq.Stops
                select s;

            foreach (var s in stops)
            {
                lat = s.Lattitude;
                longi = s.Longitude;
                GMarker mkr = new GMarker(new GLatLng(lat, longi));
                //GMap1.addGMarker(mkr);
                mManager.Add(mkr, 10);
                GMap1.Add(new GListener(mkr.ID, GListener.Event.click,
                                         "function(){prompt('Stop #: " + s.StopNo
                                             + ",  Location: " + s.Location + ",  Coordinates:"
                                             + "','" + s.Lattitude + "," + s.Longitude
                                             + "');"
                                             + "var hsn = document.getElementById('hidStopNo');"
                                             + "hsn.value = '" + s.StopNo + "';"
                                             + "}"));
            }

            GMap1.markerManager = mManager;

            if (!IsPostBack)
            {
                GMap1.setCenter(hwttc, 18);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //from here u need to remove comments
            CheckBoxList1.Style["display"] = "none";
            Table1.Rows.Clear();
            Table2.Rows.Clear();
            Table3.Rows.Clear();
            Table4.Rows.Clear();
            Table5.Rows.Clear();
            Table6.Rows.Clear();
            Table7.Rows.Clear();
            Table8.Rows.Clear();
            Table9.Rows.Clear();
            Table10.Rows.Clear();
            Table11.Rows.Clear();
            Table12.Rows.Clear();
            Table13.Rows.Clear();
            Table14.Rows.Clear();
            Table15.Rows.Clear();
            Table16.Rows.Clear();
            Table17.Rows.Clear();
            Table18.Rows.Clear();
            Table19.Rows.Clear();
            Table20.Rows.Clear();
            Globals.metromixLocalDataAllRuns.Clear();
            Globals.metromixLocalDataMerged.Clear();
            Globals.metromixLocalDataMergedSorted.Clear();
            Globals.dexknowsLocalDataAllRuns.Clear();
            Globals.dexknowsLocalDataMerged.Clear();
            Globals.dexknowsLocalDataMergedSorted.Clear();
            Globals.yelpLocalDataAllRuns.Clear();
            Globals.yelpLocalDataMerged.Clear();
            Globals.yelpLocalDataMergedSorted.Clear();
            Globals.chicagoreaderLocalDataAllRuns.Clear();
            Globals.chicagoreaderLocalDataMerged.Clear();
            Globals.chicagoreaderLocalDataMergedSorted.Clear();
            Globals.menuismLocalDataAllRuns.Clear();
            Globals.menuismLocalDataMerged.Clear();
            Globals.menuismLocalDataMergedSorted.Clear();
            Globals.menupagesLocalDataAllRuns.Clear();
            Globals.menupagesLocalDataMerged.Clear();
            Globals.menupagesLocalDataMergedSorted.Clear();
            Globals.yahooLocalDataAllRuns.Clear();
            Globals.yahooLocalDataMerged.Clear();
            Globals.yahooLocalDataMergedSorted.Clear();
            Globals.yellowpagesLocalDataAllRuns.Clear();
            Globals.yellowpagesLocalDataMerged.Clear();
            Globals.yellowpagesLocalDataMergedSorted.Clear();
            Globals.citysearchLocalDataAllRuns.Clear();
            Globals.citysearchLocalDataMerged.Clear();
            Globals.citysearchLocalDataMergedSorted.Clear();
            Globals.zagatData.Clear();
            Globals.results.Clear();
            Globals.cornersAllSelectedLocs.Clear();
            Globals.closedRestaurants.Clear();
            Globals.mergeList.Clear();

            Globals.metromixTotalQueries = 0;
            Globals.dexknowsTotalQueries = 0;
            Globals.yelpTotalQueries = 0;
            Globals.chicagoreaderTotalQueries = 0;
            Globals.menuismTotalQueries = 0;
            Globals.menupagesTotalQueries = 0;
            Globals.yahooTotalQueries = 0;
            Globals.yellowpagesTotalQueries = 0;
            Globals.citysearchTotalQueries = 0;
            Globals.zagatTotalQueries = 0;
            Globals.metromixSpan = 0;
            Globals.dexknowsSpan = 0;
            Globals.yelpSpan = 0;
            Globals.chicagoreaderSpan = 0;
            Globals.menuismSpan = 0; ;
            Globals.menupagesSpan = 0; ;
            Globals.yahooSpan = 0;
            Globals.yellowpagesSpan = 0;
            Globals.citysearchSpan = 0;
            Globals.zagatSpan = 0;

            GMap1.reset();
            GMap2.reset();
            GMap3.reset();
            GMap4.reset();
            GMap4.reset();
            GMap5.reset();
            GMap6.reset();
            GMap7.reset();
            GMap8.reset();
            GMap9.reset();
            GMap10.reset();

            MultiView1.ActiveViewIndex = 0;
            Menu1.Items[0].ImageUrl = "/images/yumiselectedtab.gif";
            Menu1.Items[0].Selected = true;
            for (int i = 1; i < Menu1.Items.Count; i++)
            {
                if (i == 1)
                    this.Menu1.Items[i].ImageUrl = "/images/metromixunselectedtab.gif";
                else if (i == 2)
                    this.Menu1.Items[i].ImageUrl = "/images/dexknowsunselectedtab.gif";
                else if (i == 3)
                    this.Menu1.Items[i].ImageUrl = "/images/yelpunselectedtab.gif";
                else if (i == 4)
                    this.Menu1.Items[i].ImageUrl = "/images/chicagoreaderunselectedtab.gif";
                else if (i == 5)
                    this.Menu1.Items[i].ImageUrl = "/images/menuismunselectedtab.gif";
                else if (i == 6)
                    this.Menu1.Items[i].ImageUrl = "/images/menupagesunselectedtab.gif";
                else if (i == 7)
                    this.Menu1.Items[i].ImageUrl = "/images/yahoounselectedtab.gif";
                else if (i == 8)
                    this.Menu1.Items[i].ImageUrl = "/images/yellowpagesunselectedtab.gif";
                else if (i == 9)
                    this.Menu1.Items[i].ImageUrl = "/images/citysearchunselectedtab.gif";
                Menu1.Items[i].Selected = false;
            }

            Globals.queryConstraints = 0;
            Globals.allData.Clear();
            for (int i = 0; i < 9; i++)
            {
                Globals.allData.Add(new List<Restaurant>());
            }
            Globals.allDataEngineTables.Clear();
            for (int i = 0; i < 9; i++)
            {
                Globals.allDataEngineTables.Add(new List<Restaurant>());
            }

            if (Globals.selected == false)
            {
                for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++)
                {
                    List<Point> chosenLoc = Globals.RectangleCoords["Metromix" + "/" + Globals.shortListedNeighborHoods[i].getName()];
                    if (Contains(chosenLoc, latlong))
                    {
                        Globals.location = Globals.shortListedNeighborHoods[i].getName();
                        break;
                    }
                    else
                    {
                        Globals.location = Globals.shortListedNeighborHoods[0].getName();
                    }
                }
            }

            else
            {
                //Label1.Text = "entered into " + Globals.selected.ToString();
                Globals.location = DropDownList1.SelectedValue;
            }
            string price = DropDownList2.SelectedValue;
            string cuisine = DropDownList3.SelectedValue;
            string keyword = TextBox1.Text;

            if (Globals.location.Equals("All") && cuisine.Equals("All") && price.Equals("") && keyword.Equals(""))
            {
                TableRow header = new TableRow();
                TableCell cell = new TableCell();
                cell.Text = "Invalid query. Please choose at least one constraint.";
                cell.Font.Bold = true;
                header.HorizontalAlign = HorizontalAlign.Center;
                header.Cells.Add(cell);
                MultiView1.ActiveViewIndex = 0;
                Table1.Rows.Add(header);
                Table1.Visible = true;
            }

            else
            {

                divImg.Visible = true;
                Globals.startTime = DateTime.Now;

                //get enabled searchengines
                Globals.enabledSE.Clear();
                for (int x = 0; x < CheckBoxList1.Items.Count; x++)
                {
                    if (CheckBoxList1.Items[x].Selected)
                        Globals.enabledSE.Add(x + 1);
                }

                //execute query
                if (!Globals.location.Equals("All"))
                    Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.LOCATION;
                if (!cuisine.Equals("All"))
                    Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.CUISINE;
                if (!price.Equals(""))
                    Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.PRICE;

                Globals.cuisine = cuisine;
                Globals.results = executeQuery(Globals.location, cuisine, price, keyword);
                string looooo = Globals.location;

                if (Globals.location.Equals("All"))
                {
                    GLatLng centerNoLoc = new GLatLng(42, -87.5);
                    GMap1.setCenter(centerNoLoc, 9);
                    placeMarkers(10);
                    GMap1.enableHookMouseWheelToZoom = true;
                    GMap2.setCenter(centerNoLoc, 9);
                    placeMarkers(0);
                    GMap2.enableHookMouseWheelToZoom = true;
                    GMap3.setCenter(centerNoLoc, 9);
                    placeMarkers(1);
                    GMap3.enableHookMouseWheelToZoom = true;
                    GMap4.setCenter(centerNoLoc, 9);
                    placeMarkers(2);
                    GMap4.enableHookMouseWheelToZoom = true;
                    GMap5.setCenter(centerNoLoc, 9);
                    placeMarkers(3);
                    GMap5.enableHookMouseWheelToZoom = true;
                    GMap6.setCenter(centerNoLoc, 9);
                    placeMarkers(4);
                    GMap6.enableHookMouseWheelToZoom = true;
                    GMap7.setCenter(centerNoLoc, 9);
                    placeMarkers(5);
                    GMap7.enableHookMouseWheelToZoom = true;
                    GMap8.setCenter(centerNoLoc, 9);
                    placeMarkers(6);
                    GMap8.enableHookMouseWheelToZoom = true;
                    GMap9.setCenter(centerNoLoc, 9);
                    placeMarkers(7);
                    GMap9.enableHookMouseWheelToZoom = true;
                    GMap10.setCenter(centerNoLoc, 9);
                    placeMarkers(8);
                    GMap10.enableHookMouseWheelToZoom = true;
                }
                else if (Globals.getLevel(Globals.location) == 1)
                {
                    List<List<Point>> cornersList = new List<List<Point>>();
                    List<GPolygon> rectangles = new List<GPolygon>();
                    List<Point> corners = new List<Point>();
                    List<Point> cornersChosenLoc = new List<Point>();
                    GPolygon target = new GPolygon();

                    cornersChosenLoc = Globals.RectangleCoords["Metromix" + "/" + Globals.location];
                    cornersList.Add(cornersChosenLoc);
                    rectangles = constructRectangles(cornersList, Rectangle.TARGET);
                    target = rectangles[0];

                    GLatLng center = new GLatLng((cornersChosenLoc[0].y + cornersChosenLoc[1].y) / 2,
                                                 (cornersChosenLoc[0].x + cornersChosenLoc[1].x) / 2);
                    GMap1.setCenter(center, 10);
                    GMap1.Add(target);
                    placeMarkers(10);
                    GMap1.enableHookMouseWheelToZoom = true;
                    GMap2.setCenter(center, 10);
                    GMap2.Add(target);
                    placeMarkers(0);
                    GMap2.enableHookMouseWheelToZoom = true;
                    GMap3.setCenter(center, 10);
                    GMap3.Add(target);
                    placeMarkers(1);
                    GMap3.enableHookMouseWheelToZoom = true;
                    GMap4.setCenter(center, 10);
                    GMap4.Add(target);
                    placeMarkers(2);
                    GMap4.enableHookMouseWheelToZoom = true;
                    GMap5.setCenter(center, 10);
                    GMap5.Add(target);
                    placeMarkers(3);
                    GMap5.enableHookMouseWheelToZoom = true;
                    GMap6.setCenter(center, 10);
                    GMap6.Add(target);
                    placeMarkers(4);
                    GMap6.enableHookMouseWheelToZoom = true;
                    GMap7.setCenter(center, 10);
                    GMap7.Add(target);
                    placeMarkers(5);
                    GMap7.enableHookMouseWheelToZoom = true;
                    GMap8.setCenter(center, 10);
                    GMap8.Add(target);
                    placeMarkers(6);
                    GMap8.enableHookMouseWheelToZoom = true;
                    GMap9.setCenter(center, 10);
                    GMap9.Add(target);
                    placeMarkers(7);
                    GMap9.enableHookMouseWheelToZoom = true;
                    GMap10.setCenter(center, 10);
                    GMap10.Add(target);
                    placeMarkers(8);
                    GMap10.enableHookMouseWheelToZoom = true;
                }
                else
                {
                    constructMap(Globals.location, 0);
                    constructMap(Globals.location, 1);
                    constructMap(Globals.location, 2);
                    constructMap(Globals.location, 3);
                    constructMap(Globals.location, 4);
                    constructMap(Globals.location, 5);
                    constructMap(Globals.location, 6);
                    constructMap(Globals.location, 7);
                    constructMap(Globals.location, 8);
                    constructMap(Globals.location, 10);
                }

                DateTime EndTime = DateTime.Now;
                TimeSpan span = EndTime.Subtract(Globals.startTime);

                Globals.results_header = "Found " + Globals.finalResultsCount + " restaurants for " + cuisine + " in " + " (" + span.Minutes + " minutes " + span.Seconds + " seconds)"+"in the radius of "+dist+"miles";
                Globals.finalResultsCountTotal = Globals.finalResultsCountTotal + Globals.finalResultsCount;

                ///////////////////////////////Testing - Timing//////////////////////////////////////////////
                //if (Globals.getLevel(Globals.location) == 1)
                //    Globals.WriteOutput(Globals.location + "," + Globals.metromixSpan + "," + Globals.dexknowsSpan + "," + Globals.yelpSpan + "," + Globals.chicagoreaderSpan + "," + Globals.menuismSpan + "," + Globals.menupagesSpan + "," + Globals.yahooSpan + "," + Globals.yellowpagesSpan + "," + Globals.citysearchSpan + "," + Globals.zagatSpan + "," + span.Seconds + ",Large Area");
                //else
                //    Globals.WriteOutput(Globals.location + "," + Globals.metromixSpan + "," + Globals.dexknowsSpan + "," + Globals.yelpSpan + "," + Globals.chicagoreaderSpan + "," + Globals.menuismSpan + "," + Globals.menupagesSpan + "," + Globals.yahooSpan + "," + Globals.yellowpagesSpan + "," + Globals.citysearchSpan + "," + Globals.zagatSpan + "," + span.Seconds);
                /////////////////////////////////////////////////////////////////////////////////////////////

                constructTable(Globals.results, 10);
                constructTable(Globals.zagatData, 9);

                if (Globals.getLevel(Globals.location) == 1)
                {
                    Globals.requestsArea++;
                    Globals.totalSecondsArea = Globals.totalSecondsArea + span.Seconds;
                }
                if (Globals.getLevel(Globals.location) == 0)
                {
                    Globals.requestsNeighborhood++;
                    Globals.totalSecondsNeighborhood = Globals.totalSecondsNeighborhood + span.Seconds;
                }

                /////////////////////////////////Testing - Verbose Timings & Google Requests//////////////////////////////////
                //try
                //{
                //    Globals.WriteOutput("Query location was " + Globals.location + " cuisine was " + cuisine + " done in " + span.Seconds);
                //    Globals.WriteOutput("  Metromix " + Globals.metromixLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.metromixLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  DexKnows " + Globals.dexknowsLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.dexknowsLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  Yelp " + Globals.yelpLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.yelpLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  ChicagoReader " + Globals.chicagoreaderLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.chicagoreaderLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  Menuism " + Globals.menuismLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.menuismLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  MenuPages " + Globals.menupagesLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.menupagesLocalDataAllRuns[0].Address);

                //    Globals.WriteOutput("  Yahoo " + Globals.yahooLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.yahooLocalDataAllRuns[0].Address);

                //    //Globals.WriteOutput("  Zagat " + Globals.zagatData[0].City);
                //    //Globals.WriteOutput("  " + Globals.zagatData[0].Address);

                //    try
                //    {
                //        Globals.WriteOutput("  YellowPages " + Globals.yellowpagesLocalDataAllRuns[0].City);
                //        Globals.WriteOutput("  " + Globals.yellowpagesLocalDataAllRuns[0].Address);
                //    }
                //    catch (Exception)
                //    {
                //        //expected exception if yellowpages thread aborted
                //    }
                //    Globals.WriteOutput("  CitySearch " + Globals.citysearchLocalDataAllRuns[0].City);
                //    Globals.WriteOutput("  " + Globals.citysearchLocalDataAllRuns[0].Address);
                //    Globals.WriteOutput("  google requests " + Globals.numberGoogleRequests);
                //}

                //catch (Exception ex)
                //{
                //    Response.Write("<script>alert('WriteOutput error')</script>");
                //    Globals.WriteOutput("THREAD ERROR");
                //}
                //////////////////////////////////////////////////////////////////////////////////////////////////
                var d2r = Math.PI / 180;   // degrees to radians
                var r2d = 180 / Math.PI;   // radians to degrees
                var earthsradius = 3963; // 3963 is the radius of the earth in miles
                var points = 32;
                //var radius = 10;
                double rlat = ((double)dist / earthsradius) * r2d;
                double rlng = rlat / Math.Cos(latitude * d2r);
                List<GLatLng> extp = new List<GLatLng>();
                for (var i = 0; i < points + 1; i++)
                {
                    double theta = Math.PI * (i / (double)(points / 2));
                    double ex = longitude + (rlng * Math.Cos(theta));
                    double ey = latitude + (rlat * Math.Sin(theta));
                    extp.Add(new GLatLng(ey, ex));
                }

                GIcon icon1 = new GIcon();
                icon1.image = "/images/urhere2.png";
                //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                icon1.iconSize = new GSize(30, 30);
                icon1.shadowSize = new GSize(22, 20);
                icon1.iconAnchor = new GPoint(6, 20);
                icon1.infoWindowAnchor = new GPoint(5, 1);
                GMarkerOptions mOpts1 = new GMarkerOptions();
                mOpts1.clickable = false;
                mOpts1.icon = icon1;
                GMarker marker1 = new GMarker(latlong, mOpts1);

                this.GMap1.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap1.addGMarker(marker1);
                this.GMap2.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap2.addGMarker(marker1);
                this.GMap3.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap3.addGMarker(marker1);
                this.GMap4.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap4.addGMarker(marker1);
                this.GMap5.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap5.addGMarker(marker1);
                this.GMap6.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap6.addGMarker(marker1);
                this.GMap7.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap7.addGMarker(marker1);
                this.GMap8.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap8.addGMarker(marker1);
                this.GMap9.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap9.addGMarker(marker1);
                this.GMap10.addPolygon(new GPolygon(extp, "#00FF00", 0.3));
                GMap10.addGMarker(marker1);

                GMap1.Visible = true;
                GMap2.Visible = true;
                GMap3.Visible = true;
                GMap4.Visible = true;
                GMap5.Visible = true;
                GMap6.Visible = true;
                GMap7.Visible = true;
                GMap8.Visible = true;
                GMap9.Visible = true;
                GMap10.Visible = true;
                Table1.Visible = true;
                Table2.Visible = true;

                //clear form
                DropDownList1.SelectedIndex = 0;
                DropDownList3.SelectedIndex = 0;

            }//till here
            //*/
        }
 public GIcon createIcon(string iconURL)
 {
     GIcon icon = new GIcon();
     icon.image = iconURL;
     icon.iconSize = new GSize(55, 55);
     icon.iconAnchor = new GPoint(16, 32);
     return icon;
 }
示例#20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GLatLng latLng = new GLatLng(39.1, -94.58);
        //creating markers with latitude and logitude, plus pushpin window and adding window in Gmap Control
        GIcon icon = new GIcon();

        //Stadium pins with window info

        GMarker marker = new GMarker(new GLatLng(36.166461, -86.771289), icon);
        GInfoWindow window = new GInfoWindow(marker, "Titans , Zip Code = 37891");
        GMap1.Add(window);
        GMarker marker1 = new GMarker(new GLatLng(40.812194, -74.076983), icon);
        GInfoWindow window1 = new GInfoWindow(marker1, "Giants , Zip Code = 10001");
        GMap1.Add(window1);
        GMarker marker2 = new GMarker(new GLatLng(40.446786, -80.015761), icon);
        GInfoWindow window2 = new GInfoWindow(marker2, "Steelers, Zip Code = 15202");
        GMap1.Add(window2);
        GMarker marker3 = new GMarker(new GLatLng(35.225808, -80.852861), icon);
        GInfoWindow window3 = new GInfoWindow(marker3, "Panthers, Zip Code = 28202");
        GMap1.Add(window3);
        GMarker marker4 = new GMarker(new GLatLng(39.277969, -76.622767), icon);
        GInfoWindow window4 = new GInfoWindow(marker4, "Ravens, Zip Code = 21203");
        GMap1.Add(window4);
        GMarker marker5 = new GMarker(new GLatLng(27.975967, -82.50335), icon);
        GInfoWindow window5 = new GInfoWindow(marker5, "Buccaneers, Zip Code = 33607");
        GMap1.Add(window5);
        GMarker marker6 = new GMarker(new GLatLng(39.760056, -86.163806), icon);
        GInfoWindow window6 = new GInfoWindow(marker6, "Colts, Zip Code = 46201");
        GMap1.Add(window6);
        GMarker marker7 = new GMarker(new GLatLng(44.973881, -93.258094), icon);
        GInfoWindow window7 = new GInfoWindow(marker7, "Vikings, Zip Code = 56760");
        GMap1.Add(window7);
        GMarker marker8 = new GMarker(new GLatLng(33.5277, -112.262608), icon);
        GInfoWindow window8 = new GInfoWindow(marker8, "Cardinals, Zip Code = 85001");
        GMap1.Add(window8);
        GMarker marker9 = new GMarker(new GLatLng(32.747778, -97.092778), icon);
        GInfoWindow window9 = new GInfoWindow(marker9, "Cowboys, Zip Code = 75203");
        GMap1.Add(window9);
        GMarker marker10 = new GMarker(new GLatLng(33.757614, -84.400972), icon);
        GInfoWindow window10 = new GInfoWindow(marker10, "Falcons, Zip code = 30303");
        GMap1.Add(window10);
        GMarker marker11 = new GMarker(new GLatLng(40.812194, -74.076983), icon);
        GInfoWindow window11 = new GInfoWindow(marker11, "Jets, Zip Code = 10001");
        GMap1.Add(window11);
        GMarker marker12 = new GMarker(new GLatLng(39.743936, -105.020097), icon);
        GInfoWindow window12 = new GInfoWindow(marker12, "Broncos, Zip Code = 28037");
        GMap1.Add(window12);
        GMarker marker13 = new GMarker(new GLatLng(25.957919, -80.238842), icon);
        GInfoWindow window13 = new GInfoWindow(marker13, "Dolphins, Zip Code = 33102");
        GMap1.Add(window13);
        GMarker marker14 = new GMarker(new GLatLng(39.900775, -75.167453), icon);
        GInfoWindow window14 = new GInfoWindow(marker14, "Eagles, Zip Code = 19092");
        GMap1.Add(window14);
        GMarker marker15 = new GMarker(new GLatLng(41.862306, -87.616672), icon);
        GInfoWindow window15 = new GInfoWindow(marker15, "Bears, Zip Code = 60602");
        GMap1.Add(window15);
        GMarker marker16 = new GMarker(new GLatLng(42.090925, -71.26435), icon);
        GInfoWindow window16 = new GInfoWindow(marker16, "Patriots, Zip Code = 58647");
        GMap1.Add(window16);
        GMarker marker17 = new GMarker(new GLatLng(38.907697, -76.864517), icon);
        GInfoWindow window17 = new GInfoWindow(marker17, "Redskins, Zip Code = 20575");
        GMap1.Add(window17);
        GMarker marker18 = new GMarker(new GLatLng(44.501306, -88.062167), icon);
        GInfoWindow window18 = new GInfoWindow(marker18, "Packers, Zip Code = 54301");
        GMap1.Add(window18);
        GMarker marker19 = new GMarker(new GLatLng(32.783117, -117.119525), icon);
        GInfoWindow window19 = new GInfoWindow(marker19, "Chargers, Zip Code = 92103");
        GMap1.Add(window19);
        GMarker marker20 = new GMarker(new GLatLng(29.950931, -90.081364), icon);
        GInfoWindow window20 = new GInfoWindow(marker20, "Saints, Zip Code = 70112");
        GMap1.Add(window20);
        GMarker marker21 = new GMarker(new GLatLng(29.684781, -95.410956), icon);
        GInfoWindow window21 = new GInfoWindow(marker21, "Texans, Zip Code = 77002");
        GMap1.Add(window21);
        GMarker marker22 = new GMarker(new GLatLng(42.773739, -78.786978), icon);
        GInfoWindow window22 = new GInfoWindow(marker22, "Bills, Zip code = 14202");
        GMap1.Add(window22);
        GMarker marker23 = new GMarker(new GLatLng(37.713486, -122.386256), icon);
        GInfoWindow window23 = new GInfoWindow(marker23, "49ers, Zip Code = 94102");
        GMap1.Add(window23);
        GMarker marker24 = new GMarker(new GLatLng(30.323925, -81.637356), icon);
        GInfoWindow window24 = new GInfoWindow(marker24, "Jaguars, Zip Code = 32099");
        GMap1.Add(window24);
        GMarker marker25 = new GMarker(new GLatLng(41.506022, -81.699564), icon);
        GInfoWindow window25 = new GInfoWindow(marker25, "Browns, Zip Code = 44114");
        GMap1.Add(window25);
        GMarker marker26 = new GMarker(new GLatLng(37.751411, -122.200889), icon);
        GInfoWindow window26 = new GInfoWindow(marker26, "Raiders, Zip Code = 94502");
        GMap1.Add(window26);
        GMarker marker27 = new GMarker(new GLatLng(39.048914, -94.484039), icon);
        GInfoWindow window27 = new GInfoWindow(marker27, "Chiefs, Zip Code = 66027");
        GMap1.Add(window27);
        GMarker marker28 = new GMarker(new GLatLng(38.632975, -90.188547), icon);
        GInfoWindow window28 = new GInfoWindow(marker28, "Rams, Zip Code = 63101");
        GMap1.Add(window28);
        GMarker marker29 = new GMarker(new GLatLng(47.595153, -122.331625), icon);
        GInfoWindow window29 = new GInfoWindow(marker29, "Seahawks, Zip Code = 98102");
        GMap1.Add(window29);
        GMarker marker30 = new GMarker(new GLatLng(39.095442, -84.516039), icon);
        GInfoWindow window30 = new GInfoWindow(marker30, "Bengals, Zip Code = 45202");
        GMap1.Add(window30);
        GMarker marker31 = new GMarker(new GLatLng(42.340156, -83.045808), icon);
        GInfoWindow window31 = new GInfoWindow(marker31, "Lions, Zip Code = 48205");
        GMap1.Add(window31);

        GMap1.Height = 350;
        GMap1.Width = 990;
        GMap1.GCenter = latLng;
        GMap1.GZoom = 4;
    }
示例#21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //reset listeners, necessary for marker listener to work between postback
            GMap1.resetListeners();

            //hide objects to be hidden
            lblDistancesError.Visible = false;
            lblStopsError.Visible = false;

            //Create default marker
            GIcon icon = new GIcon();
            icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
            icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
            icon.iconSize = new GSize(20, 28);
            icon.shadowSize = new GSize(30, 28);
            icon.iconAnchor = new GPoint(10, 18);
            icon.infoWindowAnchor = new GPoint(5, 1);

            GMap1.mapType = GMapType.GTypes.Hybrid;

            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.clickable = false;
            mOpts.icon = icon;

            GMarker marker = new GMarker(hwttc, mOpts);
            //End create default marker

            /*//Begin Listener for click map
            marker.javascript_GLatLng = "point";
            GListener listener = new GListener(marker.ID, GListener.Event.dragend, "alertame");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("function(overlay, point) {");
            sb.Append("if (overlay){");
            sb.Append("alert(overlay.id);");
            sb.Append("}");
            sb.Append("else{");
            sb.Append(marker.ToString(GMap1.GMap_Id));
            sb.Append(listener.ToString());
            sb.Append("lastclick.lat = marker.point.lat;");
            sb.Append("lastclick.lng = marker.point.lng;");
            sb.Append("txtLat.text = Convert.ToToString(lastclick.lat);");
            sb.Append("txtLong.text = Convert.ToString(lastclick.lng);");
            sb.Append("}");
            sb.Append("}");

            GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString());
            GMap1.addListener(listener2);
            //End Listener*/

            //GMap1.GZoom = 3; //set zoom level
            GMap1.Key = ConfigurationSettings.AppSettings["GoogleMapKey"];
            GMap1.enableDragging = true;
            GMap1.enableGoogleBar = false;
            GMap1.Language = "en";
            GMap1.BackColor = Color.White;
            //GMap1.enableHookMouseWheelToZoom = true;
            GMap1.enableGKeyboardHandler = true;

            //Add built-in control for selecting map type
            GMap1.addControl(new GControl(GControl.preBuilt.MapTypeControl));

            //Add built-in control for zoom and pan
            //GMap1.addControl(new GControl(GControl.preBuilt.SmallZoomControl3D));
            GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl3D));

            //Custom cursor
            GCustomCursor customCursor = new GCustomCursor(cursor.crosshair, cursor.text);
            GMap1.addCustomCursor(customCursor);

            //Mark centre with a "+"
            GControl control = new GControl(GControl.extraBuilt.MarkCenter);

            //Adds a textbox which gives the coordinates of the last click
            GMap1.addControl(new GControl(GControl.extraBuilt.TextualOnClickCoordinatesControl,
                                new GControlPosition(GControlPosition.position.Bottom_Right)));

            if (!IsPostBack)
            {
                //Set centre position of map
                GMap1.setCenter(hwttc, 18);
                //Add InfoWindow greeting
                //GInfoWindow window = new GInfoWindow(hwttc, "<b>Welcome to the HWT Transport Centre</b>");
                //GMap1.addInfoWindow(window);

                //Set up google direction capabalities
                GDirection direction = new GDirection();
                direction.autoGenerate = false;
                direction.buttonElementId = "btnPlot";
                direction.fromElementId = txtStopA.ClientID;
                direction.toElementId = txtStopB.ClientID;
                direction.divElementId = "divDirections"; direction.clearMap = true;

                // Optional
                // direction.locale = "en-En;

                GMap1.Add(direction);
            }

            //Page.RegisterClientScriptBlock("GoogleDistance", "<script language=javascript src='googleDistance.js'>");
        }
示例#22
0
        public DataTable evaluarCercanos(DataSet dsProfesores, double km)
        {
            /*KM es el rango de distancias para el que debe buscar*/

            DataTable  dtAux  = dsProfesores.Tables[0].Clone();
            DtoColegio cole   = new DtoColegio();
            CtrColegio ctrcol = new CtrColegio();

            cole.codColegio = int.Parse(Session["r"].ToString());

            ctrcol.consultarColegio(cole);
            txtCole.Text = cole.nombre;
            lblLat2.Text = cole.latitud.ToString();
            lblLng2.Text = cole.longitud.ToString();
            double lat, lng, aux = 50;

            foreach (DataTable thisTable in dsProfesores.Tables)
            {
                foreach (DataRow row in thisTable.Rows) //Para cada fila evalua la distancia
                {
                    lat = Double.Parse(row["latitud"].ToString());
                    lng = Double.Parse(row["longitud"].ToString());
                    double dist = distancia(lat, lng, Double.Parse(cole.latitud.ToString()), Double.Parse(cole.longitud.ToString()));

                    if (row["diasDisponible"].ToString().Contains(lbldia.Text))
                    {
                        if (dist < km)
                        {
                            dtAux.ImportRow(row); //Si la distancia es menor al rango "km" entonces importa la fila a mi tabla auxiliar

                            //Pinta marcador del profesor
                            GLatLng latlng  = new GLatLng(lat, lng);
                            GLatLng latlng2 = new GLatLng(Convert.ToDouble(cole.latitud.ToString()), Convert.ToDouble(cole.longitud.ToString()));

                            GIcon icon = new GIcon();
                            icon.labeledMarkerIconOptions = new LabeledMarkerIconOptions(Color.Gold, Color.White, "P", Color.Green);
                            GMarker     ii     = new GMarker(latlng, icon);
                            GInfoWindow window = new GInfoWindow(ii, "" + row["nombres"]);

                            //Pinta la linea entre profesor y colegio
                            List <GLatLng> puntos = new List <GLatLng>();
                            puntos.Add(latlng);
                            puntos.Add(latlng2);
                            GPolyline linea = new GPolyline(puntos, "FF0000", 2);
                            gmap1.Add(linea);
                            gmap1.Add(ii);
                            if (dist < aux)
                            {
                                //busca la mejor distancia
                                dista.Text   = "La mejor distancia es del profesor " + row["nombres"] + " " + row["apPaterno"] + " con " + dist.ToString() + " km de distancia.";
                                aux          = dist;
                                idProfe.Text = "" + row["codPersona"];
                            }
                            else
                            {
                            }
                        }
                        if (dtAux.Rows.Count == 0)
                        {
                            btnAmpliarRango.Enabled = true;
                        }
                    }
                }
            }

            return(dtAux);
        }
示例#23
0
    //本函数为谷歌地图
    public int fillbranchmap(GMap GMap1, DataTable dt, ref string continue2class, ref string supplierlistcontentikang, ref string supplierlistcontentciming, ref string supplierlistcontentmeinian)
    {
        GMap1.reset();

        GMap1.Add(new GControl(GControl.preBuilt.GOverviewMapControl));
        GMap1.Add(new GControl(GControl.preBuilt.LargeMapControl));

        GIcon baseIcon = new GIcon();

        baseIcon.shadow           = "http://www.google.cn/mapfiles/shadow50.png";
        baseIcon.iconSize         = new GSize(20, 34);
        baseIcon.shadowSize       = new GSize(37, 34);
        baseIcon.iconAnchor       = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        GIcon       letteredIcon;
        GMarker     marker;
        GInfoWindow window;
        double      lat, lng, clat = 0.0, clng = 0.0;
        int         index = 0;
        string      letter, lilist = "", ballooncontent;

        supplierlistcontentikang   = "";
        supplierlistcontentciming  = "";
        supplierlistcontentmeinian = "";
        int itemik = 0, itemcm = 0, itemmn = 0;

        foreach (DataRow dr in dt.Rows)
        {
            letter             = ((char)((int)'A' + index++)).ToString();
            letteredIcon       = new GIcon(baseIcon);
            letteredIcon.image = "http://www.google.cn/mapfiles/marker" + letter + ".png";

            lat    = Convert.ToDouble(dr["lat"]);
            lng    = Convert.ToDouble(dr["lng"]);
            clat  += lat;
            clng  += lng;
            marker = new GMarker(new GLatLng(lat, lng), letteredIcon);

            string sgm = "http://ditu.google.cn/maps?q=" + Server.UrlEncode(Server.UrlEncode(dr["branch"].ToString())) + "&hl=zh-CN&ie=UTF8"
                         + "&ll=" + lat + "," + lng + "&hq=" + Server.UrlEncode(Server.UrlEncode(dr["address"].ToString())) + "&z=15";

            //string sgm = "http://ditu.google.cn/maps?q=" + dr["branch"].ToString() + "&hl=zh-CN&ie=UTF8"
            //+ "&ll=" + lat + "," + lng + "&hq=" + dr["address"].ToString() + "&z=15";

            ballooncontent = "<center><b>" + dr["supplier"].ToString() + "</b><br />"
                             + "<A href='javascript:void(window.open(\"" + sgm + "\",\"_blank\"));'>" + dr["branch"].ToString() + "</A><br />"
                             + "</center>";
            window = new GInfoWindow(marker, ballooncontent, false);
            GMap1.Add(window);

            if (dt.Rows.Count == 1)
            {
                continue2class = "";
                lilist         = fillsupplierlist(index, letteredIcon.image, dr["supplier"].ToString(), dr["branch"].ToString(), dr["address"].ToString(), dr["id"].ToString(), true) + "\n\n";
            }
            else
            {
                lilist = fillsupplierlist(index, letteredIcon.image, dr["supplier"].ToString(), dr["branch"].ToString(), dr["address"].ToString(), dr["id"].ToString(), false) + "\n\n";
            }

            if (dr["supplier"].ToString() == "爱康国宾")
            {
                supplierlistcontentikang += lilist;
                itemik++;
            }
            else if (dr["supplier"].ToString() == "美年大健康")
            {
                supplierlistcontentmeinian += lilist;
                itemmn++;
            }
            else //if (dr["supplier"].ToString() == "慈铭体检")
            {
                supplierlistcontentciming += lilist;
                itemcm++;
            }
        }


        clat /= dt.Rows.Count;
        clng /= dt.Rows.Count;
        GMap1.enableHookMouseWheelToZoom = true;
        GMap1.setCenter(new GLatLng(clat, clng), 12);

        int itemmax = Math.Max(itemik, Math.Max(itemmn, itemcm));

        return(itemmax);
    }
    private void CaricaMappa()
    {
        GMap1.resetInfoWindows();
        string sDominio = Request.Url.Scheme + Uri.SchemeDelimiter + Request.Url.Host;

        //GIcon iconNostro = new GIcon();
        //iconNostro.markerIconOptions = new MarkerIconOptions(30, 30, Color.Green);
        //GIcon iconConcorr = new GIcon();
        //iconConcorr.markerIconOptions = new MarkerIconOptions(30, 30, Color.Red);

        GIcon iconNostro = new GIcon();
        iconNostro.image = sDominio + "/images/attive/ClienteNostro.png";
        iconNostro.iconSize = new GSize(15, 15);
        iconNostro.iconAnchor = new GPoint(16, 32);
        iconNostro.infoWindowAnchor = new GPoint(16, 0);

        GIcon iconConcorr = new GIcon();
        iconConcorr.image = sDominio + "/images/attive/ClienteNonNostro.png";
        iconConcorr.iconSize = new GSize(15, 15);
        iconConcorr.iconAnchor = new GPoint(16, 32);
        iconConcorr.infoWindowAnchor = new GPoint(16, 0);




        string strWhere = "";
        if (rbOpportunitaAperte.Checked)
        {
            strWhere = @"SELECT        Clienti.IDCliente, Clienti.RagioneSoc, Clienti.Indirizzo, Clienti.IDComune, Clienti.Localita, Clienti.Cap, Clienti.Provincia, Clienti.Telefono, Clienti.Cellulare, Clienti.Fax, 
                         Clienti.Mail, Clienti.bCR, Clienti.bBB, Clienti.bCG, Clienti.bCA, Clienti.bElimina, Clienti.IDFornitore, Clienti.kmDistanza, Clienti.IDZona, Clienti.DistanzaEuro, 
                         Clienti.IDListino, Clienti.Note, Clienti.GeoLat, Clienti.GeoLon, Clienti.bNostro, Opportunità.IDOpportunità, Opportunità.Descrizione, Opportunità.Prodotto, 
                         Opportunità.Importo, Opportunità.dateCreate, Opportunità.bConcluso, Opportunità.dateMod
                            FROM            Clienti INNER JOIN
                         Opportunità ON Clienti.IDCliente = Opportunità.IDCliente
                            WHERE        (Opportunità.bConcluso = 0)";


        }
        if (rbSelCentriRevisione.Checked)
        {
            strWhere = @"SELECT    *,bNostro, IDCliente, RagioneSoc, Indirizzo, Localita, Cap, Provincia, Telefono, GeoLon, GeoLat, bCA, bCG, bBB, bCR, Mail, Fax, Cellulare
                        FROM         dbo.Clienti
                        WHERE     (bCR = 1)";


        }
        if (rbTuttiClienti.Checked)
        {
            strWhere = @"SELECT        Clienti.RagioneSoc, Clienti.IDFornitore, Fornitori.RagioneSociale, Clienti.IDZona, Zone.Descrizione, Clienti.Indirizzo, Clienti.Localita, Clienti.Cap, Clienti.Provincia, 
                         Clienti.GeoLat, Clienti.GeoLon, Clienti.bCA, Clienti.bCG, Clienti.bBB, Clienti.bCR, Clienti.Telefono, Clienti.bNostro, Clienti.IDCliente
                                FROM            Fornitori RIGHT OUTER JOIN
                         Clienti INNER JOIN
                         Zone ON Clienti.IDZona = Zone.IDZona ON Fornitori.IDFornitori = Clienti.IDFornitore";
            
            if (chkZona.Checked)
            {
                if (chkOperatore.Checked)
                    strWhere += " AND ";
                else
                    strWhere += " WHERE";
                strWhere += " Clienti.IDZona=" + ddlZona.SelectedValue;
            }

        }
        if (rbPassaggio.Checked)
        {
            strWhere = @"SELECT     Clienti.RagioneSoc, Clienti.IDFornitore, Fornitori.RagioneSociale, Clienti.IDZona, Zone.Descrizione, Clienti.Indirizzo, Clienti.Localita, Clienti.Cap, 
                      Clienti.Provincia, Clienti.GeoLat, Clienti.GeoLon, Clienti.bCA, Clienti.bCG, Clienti.bBB, Clienti.bCR, Clienti.Telefono, Clienti.bNostro, Clienti.IDCliente, 
                      PassaggioCliente.DataPassaggio, PassaggioCliente.IDUtente, users.PersonalColor, users.Nome
                           ";

            if (ddlTuttiClienti.Checked)
            {
                strWhere += @"FROM         PassaggioCliente INNER JOIN
                      users ON PassaggioCliente.IDUtente = users.IDUser RIGHT OUTER JOIN
                      Clienti INNER JOIN
                      Zone ON Clienti.IDZona = Zone.IDZona ON PassaggioCliente.IDCliente = Clienti.IDCliente LEFT OUTER JOIN
                      Fornitori ON Clienti.IDFornitore = Fornitori.IDFornitori";
            }
            else{
                strWhere += @" FROM         PassaggioCliente INNER JOIN
                      users ON PassaggioCliente.IDUtente = users.IDUser INNER JOIN
                      Clienti INNER JOIN
                      Zone ON Clienti.IDZona = Zone.IDZona ON PassaggioCliente.IDCliente = Clienti.IDCliente LEFT OUTER JOIN
                      Fornitori ON Clienti.IDFornitore = Fornitori.IDFornitori";
            }


            if (chkOperatore.Checked && !ddlTuttiClienti.Checked)
            {
                strWhere += " WHERE IDUtente=" + ddlUser.SelectedValue;
            }
            if (chkZona.Checked)
            {
                if (chkOperatore.Checked)
                    strWhere += " AND ";
                else
                    strWhere += " WHERE";
                strWhere += " Clienti.IDZona=" + ddlZona.SelectedValue;
            }


            strWhere += " ORDER BY Clienti.RagioneSoc, PassaggioCliente.DataPassaggio DESC";

        }

        SqlDataAdapter adap = new SqlDataAdapter(strWhere, SqlDataSourceAssistenze.ConnectionString);
        DataTable dt = new DataTable();
        adap.Fill(dt);
        int iInseriti = 0;


        GeoCode geo = GMap.geoCodeRequest("Pradamano Via Cussignacco, 78/38", GOOGLEAPIKEY);

        string sIdCli = "";
        bool nextRow = false;
        foreach (DataRow dr in dt.Rows)
        {
            if (rbPassaggio.Checked)
            {
                nextRow = false; 
                if (sIdCli == dr["RagioneSoc"].ToString())  
                    nextRow = true;
                
                sIdCli = dr["RagioneSoc"].ToString();
            }
            if (!nextRow)
            {
                GMarker iconoDR = null;
                bool bValid = false;
                string sLocPar = dr["Localita"].ToString() + " " + dr["Indirizzo"].ToString();
                
                string sAddCli = sDominio + "/Anagrafica/Cliente.aspx?IDCli=" + dr["IDCliente"].ToString();



                if (dr["geolat"].ToString() == "" && dr["geolon"].ToString() == "")
                {
                    
                    geo = GMap.geoCodeRequest(sLocPar, GOOGLEAPIKEY);
                    if (geo.valid)
                    {
                        string UpdateCliente = "UPDATE CLienti SET GeoLat='" + geo.Placemark.coordinates.lat.ToString() + "' , GeoLon ='" + geo.Placemark.coordinates.lng.ToString() + "' WHERE IDCliente =" + dr["IDCliente"].ToString();
                        SqlConnection cnn = new SqlConnection(SqlDataSourceAssistenze.ConnectionString);
                        cnn.Open();
                        SqlCommand cmd = new SqlCommand(UpdateCliente, cnn);
                        int i = cmd.ExecuteNonQuery();
                        cnn.Close();
                    }



                    iconoDR = new GMarker(geo.Placemark.coordinates, new GIcon());

                }
                else
                {

                    GLatLng Pos = new GLatLng(double.Parse(dr["geoLat"].ToString()), double.Parse(dr["geoLon"].ToString()));
                    iconoDR = new GMarker(Pos, new GIcon());
                    bValid = true;
                }
                bool bNostro = (bool)dr["bNostro"];
                if (bNostro)
                    iconoDR.options.icon = iconNostro;
                else
                    iconoDR.options.icon = iconConcorr;

                string sMoreInfo = "";
                if (rbPassaggio.Checked)
                {
                    DateTime datePassaggio = DateTime.Now;
                    TimeSpan dateDiff;
                    int iDiff = 0;
                    bool NoPassaggio=false;
                    Color colStroke = Color.Black;
                    try
                    {
                        datePassaggio = (DateTime)dr["DataPassaggio"];
                        dateDiff = datePassaggio.Subtract(DateTime.Now);
                        iDiff = dateDiff.Days * -1;
                        colStroke = Color.FromName(dr["PersonalColor"].ToString());
                    }
                    catch
                    {
                        NoPassaggio = true;
                    }
                    
                    GIcon iconPers = new GIcon();


                    if (!NoPassaggio)
                    {
                        if (iDiff < 15)
                        {
                            iconPers.markerIconOptions = new MarkerIconOptions(30, 30, Color.PaleGreen, colStroke, colStroke);
                            iconoDR.options.icon = iconPers;
                        }
                        else if (iDiff < 30)
                        {
                            iconPers.markerIconOptions = new MarkerIconOptions(30, 30, Color.LightSkyBlue, colStroke, colStroke);
                            iconoDR.options.icon = iconPers;
                        }
                        else if (iDiff < 60)
                        {
                            iconPers.markerIconOptions = new MarkerIconOptions(30, 30, Color.Coral, colStroke, colStroke);
                            iconoDR.options.icon = iconPers;
                        }
                        else
                        {
                            iconPers.markerIconOptions = new MarkerIconOptions(30, 30, Color.Crimson, colStroke, colStroke);
                            iconoDR.options.icon = iconPers;
                        }
                        sAddCli = sDominio + "/Vendite/GestionePassaggioCliente.aspx?IDCli=" + dr["IDCliente"].ToString();

                        sMoreInfo = "</br>Operatore:<Strong>" + dr["Nome"].ToString() + "</Strong></br>Data passaggio:<Strong>" + datePassaggio.ToShortDateString() + "<Strong>";
                    }
                    else
                    {


                    }
                    
                    //GShowMapBlowUp mBlowUp = new GShowMapBlowUp(new GMarker(latlon), options);
                    //GMap1.addShowMapBlowUp(mBlowUp);
                }

                string sInfo = "<a  href='" + sAddCli + "'>" + dr["RagioneSoc"].ToString() + "</a></br>" + sLocPar + "<a>" + sMoreInfo;

                if (geo.valid | bValid)
                {

                    GInfoWindow windowDR = new GInfoWindow(iconoDR, sInfo, false, GListener.Event.click);
                    //iconoDR.options.
                    //GMap1.Add(iconoDR);
                    GMap1.Add(windowDR);
                    
                    iInseriti++;
                }
                else
                {
                    divMessage.InnerHtml += "<b>" + "<a  href='" + sAddCli + "'>" + dr["RagioneSoc"].ToString() + "</a></b> " + sLocPar + "</br>";
                }

                //bool b = GMap1.markerClusterer.markers[0].options.Visible ;

                

            }
        }

        Label1.Text = "Inseriti:" + iInseriti.ToString() + " su " + dt.Rows.Count + "elementi";

    }
示例#25
0
 public sealed override void Redraw()
 {
     if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable)
     {
         bool hide = this.Matte || !this.Viewble(this.Arise);
         {
             if (!MatchUtils.IsEmpty(this.Handle))
             {
                 if (!(this.Handle.Matte = hide))
                 {
                     GIcon v_icon = this.Handle as GIcon;
                     {
                         v_icon.Mouse = this.Mouse;
                         v_icon.Title = this.Title;
                         v_icon.Alpha = this.Alpha;
                         v_icon.Slope = this.slope;
                         v_icon.Image = this.image;
                         v_icon.Frame = this.frame;
                         v_icon.Dimen = this.dimen;
                         v_icon.Calib = this.calib;
                         v_icon.Point = this.Fit4p(this.point);
                     }
                 }
                 // 重绘图形
                 this.Facade.Dispatcher.BeginInvoke(new Action(() =>
                 {
                     if (!MatchUtils.IsEmpty(this.Handle))
                     {
                         this.Handle.Paint();
                     }
                 }));
             }
             else
             {
                 if (!((this.Handle = this.Target.Sketch.CreateIcon()).Matte = hide))
                 {
                     GIcon v_icon = this.Handle as GIcon;
                     {
                         v_icon.Matte = hide;
                         v_icon.Mouse = this.Mouse;
                         v_icon.Title = this.Title;
                         v_icon.Alpha = this.Alpha;
                         v_icon.Slope = this.slope;
                         v_icon.Image = this.image;
                         v_icon.Frame = this.frame;
                         v_icon.Dimen = this.dimen;
                         v_icon.Calib = this.calib;
                         v_icon.Point = this.Fit4p(this.point);
                     }
                     // 绘制图形
                     this.Facade.Dispatcher.BeginInvoke(new Action(() =>
                     {
                         if (!MatchUtils.IsEmpty(this.Handle))
                         {
                             v_icon.Paint();
                         }
                     }));
                 }
             }
         }
     }
 }
        private void placeMarkers(int code)
        {
            if (code == 0)
            {
                for (int i = 0; i < Globals.allDataEngineTables[0].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[0][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placMarkers" + code + ": " + Globals.allDataEngineTables[0][i].Latitude + "," + Globals.allDataEngineTables[0][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[0][i].Latitude, Globals.allDataEngineTables[0][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[0][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        //GMarker marker = new GMarker(latlng);
                        GMap2.addGMarker(marker);
                    }
                }
            }
            if (code == 1)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap3.addGMarker(marker);
                    }
                }
            }
            if (code == 2)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap4.addGMarker(marker);

                    }
                }
            }
            if (code == 3)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap5.addGMarker(marker);
                    }
                }
            }
            if (code == 4)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap6.addGMarker(marker);
                    }
                }
            }
            if (code == 5)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap7.addGMarker(marker);
                    }
                }
            }
            if (code == 6)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap8.addGMarker(marker);
                    }
                }
            }
            if (code == 7)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap9.addGMarker(marker);
                    }
                }
            }
            if (code == 8)
            {
                for (int i = 0; i < Globals.allDataEngineTables[code].Count && i < 20; i++)
                {
                    if (!Globals.allDataEngineTables[code][i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.allDataEngineTables[code][i].Latitude + "," + Globals.allDataEngineTables[code][i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.allDataEngineTables[code][i].Latitude, Globals.allDataEngineTables[code][i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.allDataEngineTables[code][i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap10.addGMarker(marker);
                    }
                }
            }
            if (code == 10)
            {
                for (int i = 0; i < Globals.results.Count && i < 20; i++)
                {
                    if (!Globals.results[i].ZipCode.Equals("99999"))
                    {
                        //Globals.WriteOutput("In placeMarkers" + code + ": " + Globals.results[i].Latitude + "," + Globals.results[i].Longitude);
                        GLatLng latlng = new GLatLng(Globals.results[i].Latitude, Globals.results[i].Longitude);
                        GIcon icon = new GIcon();
                        icon.image = "/images/blue" + Globals.results[i].Ranking + ".png";
                        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
                        icon.iconSize = new GSize(30, 30);
                        icon.shadowSize = new GSize(22, 20);
                        icon.iconAnchor = new GPoint(6, 20);
                        icon.infoWindowAnchor = new GPoint(5, 1);

                        GMarkerOptions mOpts = new GMarkerOptions();
                        mOpts.clickable = false;
                        mOpts.icon = icon;

                        GMarker marker = new GMarker(latlng, mOpts);
                        GMap1.addGMarker(marker);
                    }
                }
            }
        }
示例#27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GLatLng latLng = new GLatLng(39.1, -94.58);
        //creating markers with latitude and logitude, plus pushpin window and adding window in Gmap Control
        GIcon icon = new GIcon();

        icon.markerIconOptions = new MarkerIconOptions(20, 40);
        //Stadium pins with window info
        GMarker     marker = new GMarker(new GLatLng(36.166461, -86.771289), icon);
        GInfoWindow window = new GInfoWindow(marker, "Titans");

        GMap1.Add(window);
        GMarker     marker1 = new GMarker(new GLatLng(40.812194, -74.076983), icon);
        GInfoWindow window1 = new GInfoWindow(marker1, "Giants");

        GMap1.Add(window1);
        GMarker     marker2 = new GMarker(new GLatLng(40.446786, -80.015761), icon);
        GInfoWindow window2 = new GInfoWindow(marker2, "Steelers");

        GMap1.Add(window2);
        GMarker     marker3 = new GMarker(new GLatLng(35.225808, -80.852861), icon);
        GInfoWindow window3 = new GInfoWindow(marker3, "Panthers");

        GMap1.Add(window3);
        GMarker     marker4 = new GMarker(new GLatLng(39.277969, -76.622767), icon);
        GInfoWindow window4 = new GInfoWindow(marker4, "Ravens");

        GMap1.Add(window4);
        GMarker     marker5 = new GMarker(new GLatLng(27.975967, -82.50335), icon);
        GInfoWindow window5 = new GInfoWindow(marker5, "Buccaneers");

        GMap1.Add(window5);
        GMarker     marker6 = new GMarker(new GLatLng(39.760056, -86.163806), icon);
        GInfoWindow window6 = new GInfoWindow(marker6, "Colts");

        GMap1.Add(window6);
        GMarker     marker7 = new GMarker(new GLatLng(44.973881, -93.258094), icon);
        GInfoWindow window7 = new GInfoWindow(marker7, "Vikings");

        GMap1.Add(window7);
        GMarker     marker8 = new GMarker(new GLatLng(33.5277, -112.262608), icon);
        GInfoWindow window8 = new GInfoWindow(marker8, "Cardinals");

        GMap1.Add(window8);
        GMarker     marker9 = new GMarker(new GLatLng(32.747778, -97.092778), icon);
        GInfoWindow window9 = new GInfoWindow(marker9, "Cowboys");

        GMap1.Add(window9);
        GMarker     marker10 = new GMarker(new GLatLng(33.757614, -84.400972), icon);
        GInfoWindow window10 = new GInfoWindow(marker10, "Falcons");

        GMap1.Add(window10);
        GMarker     marker11 = new GMarker(new GLatLng(40.812194, -74.076983), icon);
        GInfoWindow window11 = new GInfoWindow(marker11, "Jets");

        GMap1.Add(window11);
        GMarker     marker12 = new GMarker(new GLatLng(39.743936, -105.020097), icon);
        GInfoWindow window12 = new GInfoWindow(marker12, "Broncos");

        GMap1.Add(window12);
        GMarker     marker13 = new GMarker(new GLatLng(25.957919, -80.238842), icon);
        GInfoWindow window13 = new GInfoWindow(marker13, "Dolphinss");

        GMap1.Add(window13);
        GMarker     marker14 = new GMarker(new GLatLng(39.900775, -75.167453), icon);
        GInfoWindow window14 = new GInfoWindow(marker14, "Eagles");

        GMap1.Add(window14);
        GMarker     marker15 = new GMarker(new GLatLng(41.862306, -87.616672), icon);
        GInfoWindow window15 = new GInfoWindow(marker15, "Bears");

        GMap1.Add(window15);
        GMarker     marker16 = new GMarker(new GLatLng(42.090925, -71.26435), icon);
        GInfoWindow window16 = new GInfoWindow(marker16, "Patriots");

        GMap1.Add(window16);
        GMarker     marker17 = new GMarker(new GLatLng(38.907697, -76.864517), icon);
        GInfoWindow window17 = new GInfoWindow(marker17, "Redskins");

        GMap1.Add(window17);
        GMarker     marker18 = new GMarker(new GLatLng(44.501306, -88.062167), icon);
        GInfoWindow window18 = new GInfoWindow(marker18, "Packers");

        GMap1.Add(window18);
        GMarker     marker19 = new GMarker(new GLatLng(32.783117, -117.119525), icon);
        GInfoWindow window19 = new GInfoWindow(marker19, "Chargers");

        GMap1.Add(window19);
        GMarker     marker20 = new GMarker(new GLatLng(29.950931, -90.081364), icon);
        GInfoWindow window20 = new GInfoWindow(marker20, "Saints");

        GMap1.Add(window20);
        GMarker     marker21 = new GMarker(new GLatLng(29.684781, -95.410956), icon);
        GInfoWindow window21 = new GInfoWindow(marker21, "Texans");

        GMap1.Add(window21);
        GMarker     marker22 = new GMarker(new GLatLng(42.773739, -78.786978), icon);
        GInfoWindow window22 = new GInfoWindow(marker22, "Bills");

        GMap1.Add(window22);
        GMarker     marker23 = new GMarker(new GLatLng(37.713486, -122.386256), icon);
        GInfoWindow window23 = new GInfoWindow(marker23, "49ers");

        GMap1.Add(window23);
        GMarker     marker24 = new GMarker(new GLatLng(30.323925, -81.637356), icon);
        GInfoWindow window24 = new GInfoWindow(marker24, "Jaguars");

        GMap1.Add(window24);
        GMarker     marker25 = new GMarker(new GLatLng(41.506022, -81.699564), icon);
        GInfoWindow window25 = new GInfoWindow(marker25, "Browns");

        GMap1.Add(window25);
        GMarker     marker26 = new GMarker(new GLatLng(37.751411, -122.200889), icon);
        GInfoWindow window26 = new GInfoWindow(marker26, "Raiders");

        GMap1.Add(window26);
        GMarker     marker27 = new GMarker(new GLatLng(39.048914, -94.484039), icon);
        GInfoWindow window27 = new GInfoWindow(marker27, "Chiefs");

        GMap1.Add(window27);
        GMarker     marker28 = new GMarker(new GLatLng(38.632975, -90.188547), icon);
        GInfoWindow window28 = new GInfoWindow(marker28, "Rams");

        GMap1.Add(window28);
        GMarker     marker29 = new GMarker(new GLatLng(47.595153, -122.331625), icon);
        GInfoWindow window29 = new GInfoWindow(marker29, "Seahawks");

        GMap1.Add(window29);
        GMarker     marker30 = new GMarker(new GLatLng(39.095442, -84.516039), icon);
        GInfoWindow window30 = new GInfoWindow(marker30, "Bengals");

        GMap1.Add(window30);
        GMarker     marker31 = new GMarker(new GLatLng(42.340156, -83.045808), icon);
        GInfoWindow window31 = new GInfoWindow(marker31, "Lions");

        GMap1.Add(window31);

        GMap1.Height  = 350;
        GMap1.Width   = 990;
        GMap1.GCenter = latLng;
        GMap1.GZoom   = 4;
    }
        private void BuildMap()
        {
            dt = BD.GetTable();
            Double lat, lng;

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    lat = Convert.ToDouble(row["latitud"].ToString().Replace('.', ','));
                    lng = Convert.ToDouble(row["longitud"].ToString().Replace('.', ','));
                    GLatLng latLng = new GLatLng(lat, lng);



                    GIcon icon = new GIcon();
                    icon.image  = "https://www.google.es/maps/vt/icon/name=icons/spotlight/spotlight-poi-medium.png&scale=2?scale=1";
                    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";

                    GMarkerOptions mOpts = new GMarkerOptions();
                    mOpts.clickable = true;
                    mOpts.icon      = icon;
                    GMarker marker = new GMarker(latLng, mOpts);
                    //GMap1.Add(marker);

                    GInfoWindow window = new GInfoWindow(marker,
                                                         string.Format(
                                                             @"<span style='color:blue;'>{0} </span><br />
                                                               <span ><b>Latitutd:</b></span> {1} <br /> 
                                                               <span ><b>Longitud:</b>:</span> {2} <br />
                                                               <b>aForo:</b> {3}",
                                                             row["name_branch"].ToString(),
                                                             row["latitud"].ToString(),
                                                             row["longitud"].ToString(),
                                                             row["aforo"].ToString()
                                                             ),
                                                         true);
                    GMap1.Add(window);
                }
            }

            KeyDragZoom keyDragZoom = new KeyDragZoom();

            keyDragZoom.key       = KeyDragZoom.HotKeyEnum.ctrl;
            keyDragZoom.boxStyle  = "{border: '4px solid #FFFF00'}";
            keyDragZoom.VeilStyle = "{backgroundColor: 'black', opacity: 0.2, cursor: 'crosshair'}";

            GMap1.Add(keyDragZoom);

            GCustomCursor customCursor = new GCustomCursor(cursor.crosshair, cursor.text);

            GMap1.Add(customCursor);

            GMap1.Add(new GControl(GControl.preBuilt.LargeMapControl));

            GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.zoomend,
                                    string.Format(@"
                   function(oldLevel, newLevel)
                   {{
                      if ((newLevel > 7) || (newLevel < 4))
                      {{
                          var ev = new serverEvent('AdvancedZoom', {0});
                          ev.addArg(newLevel);
                          ev.send();
                      }}
                   }}
                   ", GMap1.GMap_Id)));
        }
        private void drawCircle2(double lat, double lng, double radius)
        {
            // globals
            //drawing the circle with the latitude and longitude
            var d2r = Math.PI / 180;   // degrees to radians
            var r2d = 180 / Math.PI;   // radians to degrees
            var earthsradius = 3963; // 3963 is the radius of the earth in miles
            var points = 32;
            //var radius = 10;
            double rlat = ((double)radius / earthsradius) * r2d;
            double rlng = rlat / Math.Cos(lat * d2r);
            List<GLatLng> extp = new List<GLatLng>();
            for (var i = 0; i < points + 1; i++)
            {
                double theta = Math.PI * (i / (double)(points / 2));
                double ex = lng + (rlng * Math.Cos(theta));
                double ey = lat + (rlat * Math.Sin(theta));
                extp.Add(new GLatLng(ey, ex));
            }

            GIcon icon1 = new GIcon();
            icon1.image = "/images/urhere2.png";
            //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
            icon1.iconSize = new GSize(30, 30);
            icon1.shadowSize = new GSize(22, 20);
            icon1.iconAnchor = new GPoint(6, 20);
            icon1.infoWindowAnchor = new GPoint(5, 1);
            GMarkerOptions mOpts1 = new GMarkerOptions();
            mOpts1.clickable = false;
            mOpts1.icon = icon1;
            GMarker marker1 = new GMarker(latlong, mOpts1);

            this.GMap11.addPolygon(new GPolygon(extp, "##FF0000", 0.3));
            GMap11.addGMarker(marker1);

            //end of code for drawing circle with given lat long and radius
            //code for XML Retrieval

            using (reader1 = XmlReader.Create("C:/Users/Dheeraj Rampally/Desktop/dheeraj/SEM 2 ebooks/Query Processing/Project/yumi_web/yumi/xml/XMLFile1.xml"))
            {
                while (reader1.Read() && i1 <= l && j < l && k < l)
                {
                    if (reader1.IsStartElement())
                    {
                        switch (reader1.Name)
                        {
                            case "dictionary": break;
                            case "item": break;
                            case "key": break;
                            case "string": if (reader1.Read())
                                {
                                    if (reader1.Value.Trim().Contains("Metromix"))
                                    {
                                        nn[k] = reader1.Value.Trim();
                                        //Label1.Text = Label1.Text + reader.Value.Trim() + " "+"<br/>";
                                        k++;
                                    }
                                }
                                break;
                            case "value": break;
                            case "ArrayOfPoint": break;
                            case "Point": break;
                            case "x": if (reader1.Read())
                                {
                                    xcoordinates[i1] = reader1.Value.Trim();
                                    //Label2.Text += "xcoordinates[" + i1 + "]=" + reader.Value.Trim() + " " +"<br/>";
                                    i1++;
                                }
                                break;
                            case "y": if (reader1.Read())
                                {
                                    ycoordinates[j] = reader1.Value.Trim();
                                    //Label3.Text += "ycoordinates[" + j + "]=" + reader.Value.Trim() + " " + "<br/>";
                                    j++;
                                }
                                break;
                        }
                    }
                }
            }//end of code for the retrieval of XML coordinates

            //code snippet to draw a rectangle
            for (int z = 0; z <= 422; z=z+2)//looping through all the neighborhoods <=452
            {
                for (int j2 = 0; j2 < 4; j2++)//looping through all the edges within a neighborhood
                {
                    d2r = Math.PI / 180D;
                    if (j2 == 0)
                    {
                        //Haversine's Formula
                        dlong = (lng-double.Parse(xcoordinates[z])) * d2r;
                        dlat = (lat-double.Parse(ycoordinates[z])) * d2r;
                        a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2);
                        c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
                        d = 3956 * c;//3956 is radius of earth in miles
                    }
                    else if (j2 == 1)
                    {
                        //Haversine's Formula
                        dlong = (lng-double.Parse(xcoordinates[z + 1])) * d2r;
                        dlat = (lat-double.Parse(ycoordinates[z])) * d2r;
                        a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2);
                        c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
                        d = 3956 * c;
                    }
                    else if (j2 == 2)
                    {
                        //Haversine's Formula
                        dlong = (lng-double.Parse(xcoordinates[z])) * d2r;
                        dlat = (lat-double.Parse(ycoordinates[z+1])) * d2r;
                        a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2);
                        c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
                        d = 3956 * c;
                    }
                    else if (j2 == 3)
                    {
                        //Haversine's Formula
                        dlong = (lng-double.Parse(xcoordinates[z+1])) * d2r;
                        dlat = (lat-double.Parse(ycoordinates[z + 1])) * d2r;
                        a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2);
                        c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
                        d = 3956 * c;
                    }
                    distance[j2] = d;
                    //Label1.Text += distance[j2].ToString()+"<br/>";
                }
                maxElement = distance[0];//code for retriving the min element in an array
                for (int i3 = 0; i3 < 4; i3++)
                {
                    if (distance[i3] <maxElement)
                    {
                        maxElement = distance[i3];
                        //Label1.Text += "The minimum element is in loop" + x1 + "<br/>";
                    }
                }
                //x1 y2 x2 y1

                x1 = double.Parse(ycoordinates[z]);
                //Label1.Text += x1+" ";
                x3=lat;
                //Label1.Text += x2+" ";
                x2 = double.Parse(ycoordinates[z + 1]);
                //Label1.Text += x3 + "<br/>";
                if(x2<x3&&x3<x1)
                {
                    c1=true;
                  //  Label1.Text+="c1";
                }
                y1=(double.Parse(xcoordinates[z]));
                //Label1.Text += c2l + " ";
                y3=lng;
                //Label1.Text += c2m + " ";
                y2=(double.Parse(xcoordinates[z+1]));
                //Label1.Text += c2r +"<br/>";
                if((y1>y3)&&(y3>y2))
                {
                    c2=true;
                //    Label1.Text += "c2";
                }

                //vertex falling under circle

                if (radius >= maxElement)
                {
                        //code snippet to draw a rectangle
                    if (z == 0)
                    {
                        //Label1.Text += nn[0];
                        neighborhood[0] = nn[0];
                    }
                    else
                    {
                        //Label1.Text += nn[z / 2];
                        neighborhood[z / 2] = nn[z / 2];
                    }
                        GPolygon rectangle = new GPolygon();
                        List<GLatLng> rectanglePts = new List<GLatLng>();
                        rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1])));
                        rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z])));
                        rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z])));
                        rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1])));
                        rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3);
                        rectangle.clickable = true;
                        rectangle.close();
                        GMap11.Add(rectangle);
                        continue;
                }

                //circle lying inside neighborhood

                else if ((x2 < x3 && x3 < x1) && (y1 > y3 && y3 > y2))
                {
                    if (z == 0)
                    {
                        //Label1.Text += nn[0];
                        neighborhood[0] = nn[0];
                    }
                    else
                    {
                        //Label1.Text += nn[z / 2];
                        neighborhood[z / 2] = nn[z / 2];
                    }
                    GPolygon rectangle = new GPolygon();
                    List<GLatLng> rectanglePts = new List<GLatLng>();

                    rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1])));
                    rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z])));
                    rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z])));
                    rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1])));
                    rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3);
                    rectangle.clickable = true;
                    rectangle.close();
                    GMap11.Add(rectangle);
                    continue;
                }

                // the circle and line intersection with vertex lying outside circle
                    for (int j3 = 0; j3 < 4; j3++)
                    {
                        if (j3 == 0)
                        {
                            x4 = double.Parse(ycoordinates[z]);
                            y4 = double.Parse(xcoordinates[z]);
                            x5 = double.Parse(ycoordinates[z + 1]);
                            y5 = double.Parse(xcoordinates[z]);
                        }
                        if (j3 == 1)
                        {
                            x4 = double.Parse(ycoordinates[z + 1]);
                            y4 = double.Parse(xcoordinates[z]);
                            x5 = double.Parse(ycoordinates[z + 1]);
                            y5 = double.Parse(xcoordinates[z + 1]);
                        }
                        if (j3 == 2)
                        {
                            x4 = double.Parse(ycoordinates[z + 1]);
                            y4 = double.Parse(xcoordinates[z + 1]);
                            x5 = double.Parse(ycoordinates[z]);
                            y5 = double.Parse(xcoordinates[z + 1]);
                        }
                        if (j3 == 3)
                        {
                            x4 = double.Parse(ycoordinates[z]);
                            y4 = double.Parse(xcoordinates[z + 1]);
                            x5 = double.Parse(ycoordinates[z]);
                            y5 = double.Parse(xcoordinates[z]);
                        }
                        dx = x5 - x4;
                        dy = y5 - y4;
                        A = dx * dx + dy * dy;
                        B = 2 * (dx * (x4 - lat) + dy * (y4 - lng));
                        C = (x4 - lat) * (x4 - lat) + (y4 - lng) * (y4 - lng) - Math.Pow(0.014513788,2)*radius * radius;
                        det = B * B - 4 * A * C;

                        double t, ix1, iy1,ix2,iy2;
                        if ((A <= 0.0000001) || (det < 0))
                        {

                        }
                        else if(det==0)
                        {
                            t = -B / (2 * A);
                            ix1 = x4 + t * dx;
                            iy1 = y4 + t * dy;
                            if ((x4 >= ix1 && ix1 >= x5) && (y4 <= iy1 && iy1 <= y5) || (x4 <= ix1 && ix1 <= x5) && (y4 >= iy1 && iy1 >= y5))
                            {
                                if (z == 0)
                                {
                                    //Label1.Text += nn[0];
                                    neighborhood[0] = nn[0];
                                }
                                else
                                {
                                    //Label1.Text += nn[z / 2];
                                    neighborhood[z / 2] = nn[z / 2];
                                }
                                GPolygon rectangle = new GPolygon();
                                List<GLatLng> rectanglePts = new List<GLatLng>();
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1])));
                                rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3);
                                rectangle.clickable = true;
                                rectangle.close();
                                GMap11.Add(rectangle);
                            }
                        }
                        else
                        {
                            t = (-B + Math.Sqrt(det)) / (2 * A);
                            ix1 = x4 + t * dx;
                            iy1 = y4 + t * dy;
                            t = (-B - Math.Sqrt(det)) / (2 * A);
                            ix2 = x4 + t * dx;
                            iy2 = y4 + t * dy;
                            if((x4>=ix1&&ix1>=x5)&&(y4<=iy1&&iy1<=y5)&&(x4>=ix2&&ix2>=x5)&&(y4<=iy2&&iy2<=y5)||
                                (x4 <= ix1 && ix1 <= x5) && (y4 >= iy1 && iy1 >= y5) && (x4 <= ix2 && ix2 <= x5) && (y4 >= iy2 && iy2 >= y5))
                            {
                                if (z == 0)
                                {
                                    //Label1.Text += nn[0];
                                    neighborhood[0] = nn[0];
                                }
                                else
                                {
                                    //Label1.Text += nn[z / 2];
                                    neighborhood[z / 2] = nn[z / 2];
                                }
                                GPolygon rectangle = new GPolygon();
                                List<GLatLng> rectanglePts = new List<GLatLng>();
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z])));
                                rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1])));
                                rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3);
                                rectangle.clickable = true;
                                rectangle.close();
                                GMap11.Add(rectangle);
                            }
                        }
                    }

            }

            for (int i = 0, x = 0; i < neighborhood.Length; i++)
            {
                if (neighborhood[i] == null)
                    continue;
                else
                {
                    shortListednn[x] = neighborhood[i];
                    shortListednn[x] = shortListednn[x].Substring(9);
                    //Label1.Text += "ShortlistedNN " + x + "=" + shortListednn[x];
                    x++;
                }
            }

            for (int i = 0; i < Globals.hoods.Count(); i++)
            {
                for (int j = 0; j < shortListednn.Length; j++)
                {
                    if (Globals.hoods[i].getName() == shortListednn[j])
                    {
                        LocationList newHood = new LocationList(shortListednn[j]);
                        newHood = Globals.hoods[i];
                        Globals.shortListedNeighborHoods.Add(newHood);
                    }
                }

            }
            /*
            for (int i = 1; i < Globals.baba.Length; i++)
            {
                Globals.baba[i] = null;
            }

            for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++)
            {
                for (int j = 0; j < Globals.shortListedNeighborHoods[i].getLocationsCount(); j++)
                {
                    if (Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)] == null)
                    {
                        Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)] = Globals.shortListedNeighborHoods[i].getNeighborhood(j);
                        continue;
                    }
                    Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)]=Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)]+","+Globals.shortListedNeighborHoods[i].getNeighborhood(j);
                }
            }

            */

            for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++)
            {
                for (int j = 0; j < Globals.shortListedNeighborHoods[i].getLocationsCount(); j++)
                {
                    int k = Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j);
                    s1 += Globals.shortListedNeighborHoods[i].getNeighborhood(j) + k.ToString() + ",";
                    //Label1.Text+= Globals.shortListedNeighborHoods[i].getNeighborhood(j) + k.ToString() +"<br/>";

                }

                //Label1.Text += "<------------Next Set of Neighborhoods for new neighborhood--------->"+"<br/>";
            }
            //Label1.Text = s1;

            char[] seps = { ',' };
            childList = s1.Split(seps);

            //for (int i = 0; i < childList.Length - 1; i++)
            //{
            //    Label1.Text += childList[i] + "<br/>";
            //}

            for (int i = 0; i < childList.Length - 1; i++)
            {
                //Label1.Text += childList[i]+"<br/>";
                length = childList[i].Length;
                if ((childList[i].Substring(length - 1)) == "1")
                {
                    Globals.metromixList[m] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "Metromix" +Globals.metromixList[m] + " " + "<br/>";
                    m++;
                }
                else if ((childList[i].Substring(length - 1)) == "2")
                {
                    Globals.dexknowsList[d1] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "dexknows"+Globals.dexknowsList[d1] + " " + "<br/>";
                    d1++;
                }
                else if ((childList[i].Substring(length - 1)) == "3")
                {
                    Globals.yelpList[y] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "yelp"+Globals.yelpList[y] + " " + "<br/>";
                    y++;
                }
                else if ((childList[i].Substring(length - 1)) == "4")
                {
                    Globals.chicagoList[ch] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "chicagoreader"+Globals.chicagoList[ch] + " " + "<br/>";
                    ch++;
                }
                else if ((childList[i].Substring(length - 1)) == "5")
                {
                    Globals.menuList[me] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "menu"+Globals.menuList[me] + " " + "<br/>";
                    me++;
                }
                else if ((childList[i].Substring(length - 1)) == "6")
                {
                    Globals.menuPagesList[mp] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "menupages"+Globals.menuPagesList[mp] + " " + "<br/>";
                    mp++;
                }
                else if ((childList[i].Substring(length - 1)) == "7")
                {
                    Globals.yahooList[ya] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "yahoo"+Globals.yahooList[ya] + " " + "<br/>";
                    ya++;
                }
                else if ((childList[i].Substring(length - 1)) == "8")
                {
                    Globals.yellowList[ye] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "yellow"+Globals.yellowList[ye] + " " + "<br/>";
                    ye++;
                }
                else if ((childList[i].Substring(length - 1)) == "9")
                {
                    Globals.cityList[ci] = childList[i].Substring(0, length - 1);
                    //Label1.Text += "city"+Globals.cityList[ci] + " " + "<br/>";
                    ci++;
                }
                else if ((childList[i].Substring(length - 2)) == "10")
                {
                    Globals.zagatList[za] = childList[i].Substring(0, length - 2);
                    //Label1.Text += "zagat"+Globals.zagatList[za] + " " + "<br/>";
                    za++;
                }
            }

            Array.Resize(ref Globals.metromixList, m);
            Array.Resize(ref Globals.zagatList, za);
            Array.Resize(ref Globals.yellowList,ye);
            Array.Resize(ref Globals.yahooList, ya);
            Array.Resize(ref Globals.menuPagesList, mp);
            Array.Resize(ref Globals.menuList, me);
            Array.Resize(ref Globals.chicagoList, ch);
            Array.Resize(ref Globals.yelpList, y);
            Array.Resize(ref Globals.dexknowsList, d1);
            Array.Resize(ref Globals.cityList, ci);

            //for (int i = 0; i < Globals.dexknowsList.Length; i++)
            //{
            //    Label1.Text += Globals.dexknowsList[i];
            //}
        }
        /// <summary>
        /// Initialize the map
        /// </summary>
        public void InitializeMapData()
        {
            // populate map data
            var db = Sitecore.Context.Database;

            if (DataSource == null || DataSource.TemplateName != Settings.GoogleMapTemplateName)
            {
                Log.Error("Google Maps Module - could not find the data source to display the map", Settings.LoggingOwner);
                return;
            }

            try
            {
                // get map settings
                CurrentMap          = new GMap();
                CurrentMap.CanvasID = "map_canvas" + ClientID;

                // EnsureField checks whether a field is present on an item and logs errors
                Utilities.EnsureField(DataSource, "Latitude", true);
                Utilities.EnsureField(DataSource, "Longitude", true);
                CurrentMap.Center = new GLatLng(DataSource.Fields["Latitude"].Value, DataSource.Fields["Longitude"].Value);

                Utilities.EnsureField(DataSource, "Initial Zoom Level", false);
                CurrentMap.Zoom = int.Parse(DataSource.Fields["Initial Zoom Level"].Value);

                Utilities.EnsureField(DataSource, "Width", false);
                Utilities.EnsureField(DataSource, "Height", false);
                CurrentMap.Width  = int.Parse(DataSource.Fields["Width"].Value);
                CurrentMap.Height = int.Parse(DataSource.Fields["Height"].Value);

                Utilities.EnsureField(DataSource, "Map Types", false);
                CurrentMap.MapTypes = new List <string>();
                MultilistField mapTypes = ((MultilistField)DataSource.Fields["Map Types"]);
                foreach (ID mapTypeId in mapTypes.TargetIDs)
                {
                    Item mapTypeItem = db.GetItem(mapTypeId);
                    Utilities.EnsureField(mapTypeItem, "Type", true);
                    CurrentMap.MapTypes.Add(mapTypeItem.Fields["Type"].Value);
                }

                Utilities.EnsureField(DataSource, "Draggable Cursor", false);
                CurrentMap.DraggableCursor = DataSource.Fields["Draggable Cursor"].Value;

                Utilities.EnsureField(DataSource, "Dragging Cursor", false);
                CurrentMap.DraggingCursor = DataSource.Fields["Dragging Cursor"].Value;

                int tmpval;
                Utilities.EnsureField(DataSource, "Min Zoom Level", false);
                if (int.TryParse(DataSource.Fields["Min Zoom Level"].Value, out tmpval))
                {
                    CurrentMap.MinZoomLevel = tmpval;
                }
                else
                {
                    CurrentMap.MinZoomLevel = null;
                }

                Utilities.EnsureField(DataSource, "Max Zoom Level", false);
                if (int.TryParse(DataSource.Fields["Max Zoom Level"].Value, out tmpval))
                {
                    CurrentMap.MaxZoomLevel = tmpval;
                }
                else
                {
                    CurrentMap.MaxZoomLevel = null;
                }

                Utilities.EnsureField(DataSource, "Enable Double Click Zoom", false);
                CurrentMap.EnableDoubleClickZoom = ((CheckboxField)DataSource.Fields["Enable Double Click Zoom"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Dragging", false);
                CurrentMap.EnableDragging = ((CheckboxField)DataSource.Fields["Enable Dragging"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Scroll Wheel Zoom", false);
                CurrentMap.EnableScrollWheelZoom = ((CheckboxField)DataSource.Fields["Enable Scroll Wheel Zoom"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Keyboard Functionality", false);
                CurrentMap.EnableKeyboardFunctionality = ((CheckboxField)DataSource.Fields["Enable Keyboard Functionality"]).Checked;

                Utilities.EnsureField(DataSource, "Disable All Default UI Elements", false);
                CurrentMap.DisableAllDefaultUIElements = ((CheckboxField)DataSource.Fields["Disable All Default UI Elements"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Overview", false);
                CurrentMap.EnableOverview = ((CheckboxField)DataSource.Fields["Enable Overview"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Pan Control", false);
                CurrentMap.EnablePanControl = ((CheckboxField)DataSource.Fields["Enable Pan Control"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Scale Control", false);
                CurrentMap.EnableScaleControl = ((CheckboxField)DataSource.Fields["Enable Scale Control"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Street View Control", false);
                CurrentMap.EnableStreetViewControl = ((CheckboxField)DataSource.Fields["Enable Street View Control"]).Checked;

                Utilities.EnsureField(DataSource, "Enable Zoom Control", false);
                CurrentMap.EnableZoomControl = ((CheckboxField)DataSource.Fields["Enable Zoom Control"]).Checked;

                // get all markers
                CurrentMap.Markers  = new List <GMarker>();
                CurrentMap.Lines    = new List <GLine>();
                CurrentMap.Polygons = new List <GPolygon>();

                if (DataSource.HasChildren)
                {
                    foreach (Item childElement in DataSource.Children)
                    {
                        if (childElement.TemplateName == Settings.LocationTemplateName)
                        {
                            GMarker marker = new GMarker();

                            Utilities.EnsureField(childElement, "Latitude", true);
                            Utilities.EnsureField(childElement, "Longitude", true);
                            marker.Position = new GLatLng(childElement.Fields["Latitude"].Value, childElement.Fields["Longitude"].Value);
                            marker.Title    = childElement.Name;
                            Utilities.EnsureField(childElement, "Text", false);
                            marker.InfoWindow = childElement.Fields["Text"].Value;

                            // check if marker has a custom icon
                            if (childElement.Fields["Custom Icon"] != null && childElement.Fields["Custom Icon"].HasValue && ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem != null)
                            {
                                Item  customIcon = ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem;
                                GIcon icon       = new GIcon();
                                Utilities.EnsureField(customIcon, "Image", true);
                                icon.ImageURL        = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]).MediaItem));
                                icon.ImageDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]);

                                Utilities.EnsureField(customIcon, "Anchor", false);
                                icon.Anchor = Utilities.StringToPoint(customIcon.Fields["Anchor"].Value);

                                Utilities.EnsureField(customIcon, "Shadow Image", false);
                                if (customIcon.Fields["Shadow Image"].HasValue && ((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem != null)
                                {
                                    icon.ShadowURL        = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem));
                                    icon.ShadowDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]);
                                    Utilities.EnsureField(customIcon, "Shadow Anchor", false);
                                    icon.ShadowAnchor = Utilities.StringToPoint(customIcon.Fields["Shadow Anchor"].Value);
                                }

                                Utilities.EnsureField(customIcon, "Clickable Polygon", false);
                                if (customIcon.Fields["Clickable Polygon"].HasValue && !string.IsNullOrEmpty(customIcon.Fields["Clickable Polygon"].Value))
                                {
                                    icon.ClickablePolygon = customIcon.Fields["Clickable Polygon"].Value;
                                }

                                marker.CustomIcon = icon;
                            }

                            CurrentMap.Markers.Add(marker);
                        }
                        else if (childElement.TemplateName == Settings.LineTemplateName)
                        {
                            GLine line = new GLine();
                            Utilities.EnsureField(childElement, "Stroke Color", false);
                            line.StrokeColor = childElement.Fields["Stroke Color"].Value;

                            Utilities.EnsureField(childElement, "Stroke Opacity", false);
                            line.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value);

                            Utilities.EnsureField(childElement, "Stroke Weight", false);
                            line.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value);

                            Utilities.EnsureField(childElement, "Points", false);
                            var points = ((MultilistField)childElement.Fields["Points"]).Items;
                            line.Points = Utilities.ArrayToLatLngList(points);

                            CurrentMap.Lines.Add(line);
                        }
                        else if (childElement.TemplateName == Settings.PolygonTemplateName)
                        {
                            GPolygon poly = new GPolygon();
                            Utilities.EnsureField(childElement, "Stroke Color", false);
                            poly.StrokeColor = childElement.Fields["Stroke Color"].Value;

                            Utilities.EnsureField(childElement, "Stroke Opacity", false);
                            poly.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value);

                            Utilities.EnsureField(childElement, "Stroke Weight", false);
                            poly.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value);

                            Utilities.EnsureField(childElement, "Points", false);
                            var points = ((MultilistField)childElement.Fields["Points"]).Items;
                            poly.Points = Utilities.ArrayToLatLngList(points);

                            Utilities.EnsureField(childElement, "Fill Color", false);
                            poly.FillColor = childElement.Fields["Fill Color"].Value;

                            Utilities.EnsureField(childElement, "Fill Opacity", false);
                            poly.FillOpacity = Utilities.EnsureOpacity(childElement.Fields["Fill Opacity"].Value);

                            Utilities.EnsureField(childElement, "Is Clickable", false);
                            poly.Clickable = ((CheckboxField)childElement.Fields["Is Clickable"]).Checked;

                            Utilities.EnsureField(childElement, "Text", false);
                            poly.InfoWindow = childElement.Fields["Text"].Value;

                            CurrentMap.Polygons.Add(poly);
                        }
                    }
                }
            }
            catch (FieldValidationException)
            {
                // this has been logged already - nothing to do here.
            }
            catch (Exception ex)
            {
                Log.Error("Google Maps Module - could not initialize the map", ex, Settings.LoggingOwner);
            }
        }