Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(42.12, -1.145);
            GMap1.setCenter(latlng, 5, GMapType.GTypes.Hybrid);

            GMarker marker = new GMarker(latlng);
            GInfoWindowOptions windowOptions = new GInfoWindowOptions(12, GMapType.GTypes.Normal);
            //GShowMapBlowUp mbUp = new GShowMapBlowUp(marker, false, IWoptions);
            //GMap1.addShowMapBlowUp(mbUp);
            GInfoWindow mbUp = new GInfoWindow(marker, "I'm an infoWindow", windowOptions);
            GMap1.Add(mbUp);

            GMap1.Add(new GMarker(latlng + new GLatLng(2, 1)));

            GMarkerOptions markerOptions = new GMarkerOptions();
            markerOptions.clickable = false;
            GMarker marker2 = new GMarker(latlng + new GLatLng(-1, 2.5), markerOptions);
            GMap1.Add(marker2);

            GMarker markerDraggable = new GMarker(latlng + new GLatLng(-2, -1));
            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.draggable = true;
            markerDraggable.options = mOpts;
            // string jsStart = "function() {" + GMap1.GMap_Id + ".closeInfoWindow();}";
            // string jsEnd = "function() {" + markerDraggable.ID + ".openInfoWindowHtml('<a href=\"http://www.playsudoku.biz\" target=\"_blank\">Play Sudoku</a>');}";
            string jsStart = "function() { if (typeof variable !== myInfoWindow) {myInfoWindow.close(); } }";
            string jsEnd = "function() { myInfoWindow = new google.maps.InfoWindow({ content: '<a href=\"http://www.playsudoku.biz\" target=\"_blank\">Play Sudoku</a>' }); myInfoWindow.open(" + GMap1.GMap_Id + "," + markerDraggable.ID + "); }";
            GMap1.Add(new GListener(markerDraggable.ID, GListener.Event.dragstart, jsStart));
            GMap1.Add(new GListener(markerDraggable.ID, GListener.Event.dragend, jsEnd));
            GMap1.Add(markerDraggable);
        }
Ejemplo n.º 3
0
        private void FillHome()
        {
            GLatLng gLatLng = null;

            if (Lat.HasValue)
            {
                gLatLng = new GLatLng(Lat.Value, Lon.Value);
            }
            else if (Address != null)
            {
                GeoCode geoCode = GMap1.getGeoCodeRequest(Address);
                if (geoCode.valid)
                {
                    gLatLng = geoCode.Placemark.coordinates;
                }
            }
            if (gLatLng != null)
            {
                PinIcon pinIcon       = new PinIcon(PinIcons.home, Color.FromArgb(0xB4, 0x97, 0x59));
                var     markerOptions = new GMarkerOptions(new GIcon(pinIcon.ToString(), pinIcon.Shadow()),
                                                           Title.Replace("'", "´"));
                GMarker marker = new GMarker(gLatLng, markerOptions);
                //GMarker marker = new GMarker(gLatLng);
                StringBuilder sb = new StringBuilder();
                sb.Append(Title);
                GInfoWindow window = new GInfoWindow(marker, sb.ToString(), false);
                GMap1.addInfoWindow(window);
                GMap1.setCenter(new GLatLng(gLatLng.lat, gLatLng.lng), InitialZoom);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(41, -3.2);

            GMap1.setCenter(latlng, 5, GMapType.GTypes.Satellite);

            GMarkerOptions mOpts = new GMarkerOptions();

            mOpts.draggable = true;
            GMarker marker = new GMarker(latlng, mOpts);

            GMap1.Add(marker);
            GListener listener = new GListener(marker.ID, GListener.Event.dragend, "alertame");

            GMap1.Add(listener);

            GMarker mkr = new GMarker();

            mkr.options            = mOpts;
            mkr.javascript_GLatLng = "mouseEvent.latLng";
            listener = new GListener(mkr.ID, GListener.Event.dragend, "alertame");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("function(mouseEvent) {");
            sb.Append(mkr.ToString(GMap1.GMap_Id));
            sb.Append(listener.ToString());
            sb.Append("}");

            GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString());

            GMap1.Add(listener2);

            GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.moveend, "function() {alert('I Love Elvis :9P');}"));

            GPolygon polygon = new GPolygon();

            polygon.Add(latlng + new GLatLng(1, 1));
            polygon.Add(latlng + new GLatLng(2, 3));
            polygon.Add(latlng + new GLatLng(4, 4));
            polygon.close();
            GMap1.Add(polygon);

            GListener listener3 = new GListener(polygon.PolygonID, GListener.Event.click, "function(mouseEvent) {alert('Polygon clicked');}");

            GMap1.Add(listener3);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(41, -3.2);
            GMap1.setCenter(latlng, 5, GMapType.GTypes.Satellite);

            GMarkerOptions mOpts = new GMarkerOptions();
            mOpts.draggable = true;
            GMarker marker = new GMarker(latlng, mOpts);
            GMap1.Add(marker);
            GListener listener = new GListener(marker.ID, GListener.Event.dragend, "alertame");
            GMap1.Add(listener);

            GMarker mkr = new GMarker();
            mkr.options = mOpts;
            mkr.javascript_GLatLng = "mouseEvent.latLng";
            listener = new GListener(mkr.ID, GListener.Event.dragend, "alertame");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("function(mouseEvent) {");
            sb.Append(mkr.ToString(GMap1.GMap_Id));
            sb.Append(listener.ToString());
            sb.Append("}");

            GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString());
            GMap1.Add(listener2);

            GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.moveend, "function() {alert('I Love Elvis :9P');}"));

            GPolygon polygon = new GPolygon();
            polygon.Add(latlng + new GLatLng(1, 1));
            polygon.Add(latlng + new GLatLng(2, 3));
            polygon.Add(latlng + new GLatLng(4, 4));
            polygon.close();
            GMap1.Add(polygon);

            GListener listener3 = new GListener(polygon.PolygonID, GListener.Event.click, "function(mouseEvent) {alert('Polygon clicked');}");
            GMap1.Add(listener3);
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            gMap.setCenter(_latlng, 7, GMapType.GTypes.Hybrid);
            gMap.enableHookMouseWheelToZoom = true;

            //show the postion on the map
            gMap.addControl(new GControl(GControl.extraBuilt.TextualCoordinatesControl));

            //show the cursor on the map
            gMap.addControl(new GControl(GControl.extraBuilt.MarkCenter));

            gMap.setCenter(_latlng, 5, GMapType.GTypes.Satellite);

            var mOpts = new GMarkerOptions {draggable = true};

            var mkr = new GMarker {options = mOpts, javascript_GLatLng = "point"};

            var sb = "function(overlay, point) {if (overlay){alert(overlay.id);} else{#ID#}}";
            sb = sb.Replace("#ID#", mkr.ToString(gMap.GMap_Id));

            var listener2 = new GListener(gMap.GMap_Id, GListener.Event.click, sb);
            gMap.addListener(listener2);
        }
Ejemplo n.º 11
0
        protected GMarker CreateMarker(GLatLng FromPoint)
        {
            GMarker        _Marker  = new GMarker(FromPoint);
            GMarkerOptions _options = new GMarkerOptions();

            _options.draggable = true;
            _Marker.options    = _options;

            locationGMap.Add(_Marker);

            locationGMap.addListener(new GListener(_Marker.ID, GListener.Event.dragend,
                                                   string.Format(@"
               function(overlay, point)
               {{
                  var ev = new serverEvent('myDragEnd', {0});
                  ev.addArg({0}.getZoom());
                  ev.addArg({1}.position.lng());
                  ev.addArg({1}.position.lat());
                  ev.send();
               }}
               ", locationGMap.GMap_Id, _Marker.ID)));

            locationGMap.addListener(new GListener(locationGMap.GMap_Id, GListener.Event.click,
                                                   string.Format(@"
               function(overlay, marker)
               {{
                  {1}.setPosition({0}.getCenter());
                  var ev = new serverEvent('myDragEnd', {0});
                  ev.addArg({0}.getZoom());
                  ev.addArg({1}.position.lng());
                  ev.addArg({1}.position.lat());
                  ev.send();
               }}
               ", locationGMap.GMap_Id, _Marker.ID)));

            return(_Marker);
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GLatLng latlng = new GLatLng(42.12, -1.145);

            GMap1.setCenter(latlng, 5, GMapType.GTypes.Hybrid);

            GMarker            marker        = new GMarker(latlng);
            GInfoWindowOptions windowOptions = new GInfoWindowOptions(12, GMapType.GTypes.Normal);
            //GShowMapBlowUp mbUp = new GShowMapBlowUp(marker, false, IWoptions);
            //GMap1.addShowMapBlowUp(mbUp);
            GInfoWindow mbUp = new GInfoWindow(marker, "I'm an infoWindow", windowOptions);

            GMap1.Add(mbUp);

            GMap1.Add(new GMarker(latlng + new GLatLng(2, 1)));

            GMarkerOptions markerOptions = new GMarkerOptions();

            markerOptions.clickable = false;
            GMarker marker2 = new GMarker(latlng + new GLatLng(-1, 2.5), markerOptions);

            GMap1.Add(marker2);

            GMarker        markerDraggable = new GMarker(latlng + new GLatLng(-2, -1));
            GMarkerOptions mOpts           = new GMarkerOptions();

            mOpts.draggable         = true;
            markerDraggable.options = mOpts;
            // string jsStart = "function() {" + GMap1.GMap_Id + ".closeInfoWindow();}";
            // string jsEnd = "function() {" + markerDraggable.ID + ".openInfoWindowHtml('<a href=\"http://www.playsudoku.biz\" target=\"_blank\">Play Sudoku</a>');}";
            string jsStart = "function() { if (myInfoWindow) {myInfoWindow.close(); } }";
            string jsEnd   = "function() { myInfoWindow = new google.maps.InfoWindow({ content: '<a href=\"http://www.playsudoku.biz\" target=\"_blank\">Play Sudoku</a>' }); myInfoWindow.open(" + GMap1.GMap_Id + "," + markerDraggable.ID + "); }";

            GMap1.Add(new GListener(markerDraggable.ID, GListener.Event.dragstart, jsStart));
            GMap1.Add(new GListener(markerDraggable.ID, GListener.Event.dragend, jsEnd));
            GMap1.Add(markerDraggable);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        private void CriaNovoMarcador(double latitude, double longitude, string caminhoImagem, string texto)
        {
            GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));
            GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));
            GMarker marker = new GMarker(new GLatLng(latitude, longitude));
            GMarkerOptions markerOptions = new GMarkerOptions(new GIcon(caminhoImagem));
            marker.options = markerOptions;
            GInfoWindow window;
            window = new GInfoWindow(marker, texto, false);
            GMap1.addInfoWindow(window);

            GMap1.setCenter(marker.point);
        }
        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);
                    }
                }
            }
        }
Ejemplo n.º 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);
    }
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MapaPrueba.Language       = "es";
            MapaPrueba.GZoom          = 17;
            MapaPrueba.mapType        = TipoMapa;
            MapaPrueba.enableRotation = true;
            MarketOPciones.draggable  = true;
            Marcador.options          = MarketOPciones;
            MapaPrueba.Add(ventana);
            MapaPrueba.Add(new GMapUI());
            MapaPrueba.resetInfoWindows();
            if (Session["IdUsuario"] != null)
            {
                if (!IsPostBack)
                {
                    Session["MVDireccion"]         = MVDireccion;
                    Session["MVUsuario"]           = MVUsuario;
                    Session["MVTelefono"]          = MVTelefono;
                    Session["MVUbicacion"]         = MVUbicacion;
                    Session["MVCorreoElectronico"] = MVCorreoElectronico;
                    //Sesiones de la ubicacion
                    Session["TipoMapa"]                = TipoMapa;
                    Session["MarketOPciones"]          = MarketOPciones;
                    Session["Marcador"]                = Marcador;
                    Session["PlantillaMensajeVentana"] = PlantillaMensajeVentana;
                    Session["Zoom"]       = Zoom;
                    Session["DbLatitud"]  = DbLatitud;
                    Session["DbLongitud"] = DbLongitud;

                    MuestraPanel("General");

                    DDLDPais.DataSource     = MVDireccion.Paises();
                    DDLDPais.DataValueField = "UidPais";
                    DDLDPais.DataTextField  = "Nombre";
                    DDLDPais.DataBind();

                    MVTelefono.TipoDeTelefonos();
                    DDLDTipoDETelefono.DataSource     = MVTelefono.ListaDeTipoDeTelefono;
                    DDLDTipoDETelefono.DataValueField = "UidTipo";
                    DDLDTipoDETelefono.DataTextField  = "StrNombreTipoDeTelefono";
                    DDLDTipoDETelefono.DataBind();

                    EstatusPanelDatosGenerales(false);
                    EstatusControlesTelefono(false);
                    Cargausuario(Session["IdUsuario"].ToString());

                    EstatusDeCamposDeDireccion(false);
                    DgvDirecciones.Enabled = true;
                    PanelMensaje.Visible   = false;
                }
                else
                {
                    MVDireccion         = (VMDireccion)Session["MVDireccion"];
                    MVUsuario           = (VMUsuarios)Session["MVUsuario"];
                    MVTelefono          = (VMTelefono)Session["MVTelefono"];
                    MVUbicacion         = (VMUbicacion)Session["MVUbicacion"];
                    MVCorreoElectronico = (VMCorreoElectronico)Session["MVCorreoElectronico"];
                    //Sesiones de la ubicacion
                    TipoMapa                = (GMapType.GTypes)Session["TipoMapa"];
                    MarketOPciones          = (GMarkerOptions)Session["MarketOPciones"];
                    Marcador                = (GMarker)Session["Marcador"];
                    PlantillaMensajeVentana = (string)Session["PlantillaMensajeVentana"];
                    Zoom = (int)Session["Zoom"];
                }
            }
            else
            {
                Response.Redirect("../Default/");
            }
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Maps
            GLatLng centerCoordinates = new GLatLng(55.2, 9.5);
            GMap1.setCenter(centerCoordinates);
            GMap1.GZoom = 7;
            GMap1.enableHookMouseWheelToZoom = true;
            GMap1.enableDoubleClickZoom = true;
            #endregion

            XMLReader xmlReader = new XMLReader();
            List<Flight> listOfFlights = xmlReader.readFromFile();
            foreach (Flight flight in listOfFlights)
            {
                GLatLng coordinates = new GLatLng(flight.Plots[0].latitude, flight.Plots[0].longitude);
                GIcon icon = createIcon(chooseIcon(calculateDirection(flight.Plots[0].latitude, flight.Plots[0].longitude, flight.Plots[1].latitude, flight.Plots[1].longitude)));
                GMarkerOptions mOpts = new GMarkerOptions();
                mOpts.icon = icon;
                GMarker marker = new GMarker(coordinates, mOpts);
                GMap1.Add(marker);
               }
        }
        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
            //*/
        }
Ejemplo n.º 21
0
        private void BindData(SelectedHotelsEntities db, GLatLng point, double distance)
        {
            int?hotelTypeId = null;

            if (Settings["hoteltype"] != null)
            {
                hotelTypeId = Convert.ToInt32(Settings["hoteltype"]);
            }
            var location = DbGeography.FromText(String.Format("POINT({0} {1})", point.lng, point.lat));
            var hotels   = from hotel in db.Products.Where(p => !p.IsDeleted).OfType <Hotel>()
                           let dist = hotel.Location.Distance(location) * .00062
                                      where
                                      !hotel.IsDeleted && hotel.Location != null && hotel.Location.Latitude != null &&
                                      hotel.Location.Longitude != null &&
                                      dist <= distance &&
                                      (hotelTypeId == null || hotel.HotelTypeId == hotelTypeId)
                                      select new HotelView
            {
                Id               = hotel.Id,
                Name             = hotel.Name,
                Number           = hotel.Number,
                UnitCost         = hotel.UnitCost,
                Description      = hotel.Description,
                URL              = hotel.URL,
                Image            = hotel.Image,
                ExtraDescription = hotel.ExtraDescription,
                CurrencyCode     = hotel.CurrencyCode,
                Rooms            = hotel.Rooms,
                Star             = hotel.Star,
                CustomerRating   = hotel.CustomerRating,
                Address          = hotel.Address,
                PostCode         = hotel.PostCode,
                Location         = hotel.Location,
                Distance         = dist,
                GeoName          = hotel.GeoName
            };

            if (Session["filter"] != null)
            {
                hotels =
                    hotels.Where(
                        p =>
                        p.Name.ToLower().Contains(TextBoxFilter.Text.ToLower()) ||
                        p.Description.ToLower().Contains(TextBoxFilter.Text.ToLower()));
                LabelFilteredBy.Text      = String.Format("and filtered by \"{0}\"", TextBoxFilter.Text);
                LabelFilteredBy.Visible   = true;
                ButtonClearFilter.Visible = true;
            }
            else
            {
                LabelFilteredBy.Visible   = false;
                ButtonClearFilter.Visible = false;
            }
            List <HotelView> hotelList = null;

            Enums.SortCriteriaEnum sortCriteria = (Enums.SortCriteriaEnum)Enum.Parse(typeof(Enums.SortCriteriaEnum), DropDownListSortCriterias.SelectedValue);
            switch (sortCriteria)
            {
            case Enums.SortCriteriaEnum.Name:
                hotels = hotels.OrderBy(h => h.Name);
                break;

            case Enums.SortCriteriaEnum.PriceAsc:
                hotels = hotels.OrderBy(h => h.UnitCost);
                break;

            case Enums.SortCriteriaEnum.PriceDesc:
                hotels = hotels.OrderByDescending(h => h.UnitCost);
                break;

            case Enums.SortCriteriaEnum.RatingAsc:
                hotels = hotels.OrderBy(h => h.Star);
                break;

            case Enums.SortCriteriaEnum.RatingDesc:
                hotels = hotels.OrderByDescending(h => h.Star);
                break;

            case Enums.SortCriteriaEnum.DistanceAsc:
                hotels = hotels.OrderBy(h => h.Distance);
                break;

            case Enums.SortCriteriaEnum.DistanceDesc:
                hotels = hotels.OrderByDescending(h => h.Distance);
                break;
            }
            ListViewContent.DataSource = hotels.ToList();
            ListViewContent.DataBind();

            var count = hotels.Count();

            DataPagerContent.Visible  = count > DataPagerContent.PageSize;
            DataPagerContent2.Visible = count > DataPagerContent2.PageSize;
            LabelCount.Text           = count.ToString();

            int i = DataPagerContent.StartRowIndex + 1;

            foreach (var hotel in hotels.Skip(DataPagerContent.StartRowIndex).Take(DataPagerContent.PageSize))
            {
                GLatLng       gLatLng       = new GLatLng(hotel.Location.Latitude.Value, hotel.Location.Longitude.Value);
                PinLetter     pinLetter     = new PinLetter(i.ToString(), Color.FromArgb(0xB4, 0x97, 0x59), Color.Black);
                var           markerOptions = new GMarkerOptions(new GIcon(pinLetter.ToString(), pinLetter.Shadow()), hotel.Name.Replace("'", "´"));
                GMarker       marker        = new GMarker(gLatLng, markerOptions);
                StringBuilder sb            = new StringBuilder();
                sb.Append(hotel.Name);
                sb.AppendFormat("<br />Address:&nbsp;{0}", hotel.Address);
                GInfoWindow window = new GInfoWindow(marker, sb.ToString(), false);
                locationGMap.addInfoWindow(window);
                i++;
            }
        }
        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];
            //}
        }
Ejemplo n.º 23
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'>");
        }
Ejemplo n.º 24
0
        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)));
        }