private void arreglarMapa() { GMap1.Add(new GControl(GControl.preBuilt.LargeMapControl)); GMap1.enableHookMouseWheelToZoom = true; StringBuilder sb = new StringBuilder(); sb.Append("function(marker, point) {"); GLatLng latlng = new GLatLng("point"); GInfoWindow window = new GInfoWindow(latlng, "<div style=\"height:140px;\"><blink>Loading...</blink></div>"); sb.Append(window.ToString(GMap1.GMap_Id)); sb.Append("}"); GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString())); StringBuilder sb2 = new StringBuilder(); sb2.Append("function goTo(point){"); GLatLng point = new GLatLng("point"); sb2.AppendFormat("{0}.setZoom(11);", GMap1.GMap_Id); GMove move = new GMove(1, point); sb2.Append(move.ToString(GMap1.GMap_Id)); GMarker marker = new GMarker(point); sb2.Append(marker.ToString(GMap1.GMap_Id)); sb2.Append("}"); GMap1.Add(sb2.ToString()); }
protected string GMap1_ServerEvent(object s, GAjaxServerEventOtherArgs e) { string js = string.Empty; switch (e.eventName) { case "Click": GLatLng latlng = new GLatLng( Convert.ToDouble(e.eventArgs[2], new System.Globalization.CultureInfo("en-US", false)), Convert.ToDouble(e.eventArgs[3], new System.Globalization.CultureInfo("en-US", false))); GInfoWindow window = new GInfoWindow(latlng, string.Format("Window Size (px): ({0},{1}). Close Me.", e.eventArgs[0], e.eventArgs[1])); GListener listener = new GListener(window.ID, GListener.Event.infowindowclose, string.Format( @" function() {{ var ev = new serverEvent('InfoWindowClose', {0}); ev.addArg('My Argument'); ev.send(); }} ", window.ID)); js = window.ToString(e.who) + listener.ToString(); break; case "InfoWindowClose": js = string.Format ("alert('{0}: {1} - {2} - {3}')", e.eventName, e.point, e.eventArgs[0], DateTime.Now); break; } return js; }
protected string GMap1_DragEnd(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, "DragEnd - " + DateTime.Now.ToString(), false); return(window.ToString(e.map)); }
private void arreglarMapa() { GMap1.Add(new GControl(GControl.preBuilt.LargeMapControl)); GMap1.enableHookMouseWheelToZoom = true; StringBuilder sb = new StringBuilder(); sb.Append("function(marker, point) {"); GLatLng latlng = new GLatLng("point"); GInfoWindow window = new GInfoWindow(latlng, "<div style=\"height:140px;\"><blink>Loading...</blink></div>"); sb.Append(window.ToString(GMap1.GMap_Id)); sb.Append("}"); GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString())); StringBuilder sb2 = new StringBuilder(); sb2.Append("function goTo(point){"); GLatLng point = new GLatLng("point"); sb2.AppendFormat("{0}.setZoom(11);", GMap1.GMap_Id); GMove move = new GMove(1, point); sb2.Append(move.ToString(GMap1.GMap_Id)); GMarker marker = new GMarker(point); sb2.Append(marker.ToString(GMap1.GMap_Id)); sb2.Append("}"); GMap1.Add(sb2.ToString()); }
protected string GMap1_ServerEvent(object s, GAjaxServerEventOtherArgs e) { string js = string.Empty; switch (e.eventName) { case "Click": GLatLng latlng = new GLatLng( Convert.ToDouble(e.eventArgs[2], new System.Globalization.CultureInfo("en-US", false)), Convert.ToDouble(e.eventArgs[3], new System.Globalization.CultureInfo("en-US", false))); GInfoWindowOptions options = new GInfoWindowOptions(); options.onCloseFn = string.Format(@" function() {{ var ev = new serverEvent('InfoWindowClose', {0}); ev.addArg('My Argument'); ev.send(); }} ", GMap1.GMap_Id); GInfoWindow window = new GInfoWindow(latlng, string.Format("Window Size (px): ({0},{1}). Close Me.", e.eventArgs[0], e.eventArgs[1]), options); //guardar punto Session["lat"] = latlng.lat.ToString(); Session["lng"] = latlng.lng.ToString(); js = window.ToString(e.who); break; } return(js); }
protected string GMap1_ServerEvent(object s, GAjaxServerEventOtherArgs e) { string js = string.Empty; switch (e.eventName) { case "Click": GLatLng latlng = new GLatLng( Convert.ToDouble(e.eventArgs[2], new System.Globalization.CultureInfo("en-US", false)), Convert.ToDouble(e.eventArgs[3], new System.Globalization.CultureInfo("en-US", false))); GInfoWindow window = new GInfoWindow(latlng, string.Format("Window Size (px): ({0},{1}). Close Me.", e.eventArgs[0], e.eventArgs[1])); GListener listener = new GListener(window.ID, GListener.Event.infowindowclose, string.Format( @" function() {{ var ev = new serverEvent('InfoWindowClose', {0}); ev.addArg('My Argument'); ev.send(); }} ", window.ID)); js = window.ToString(e.who) + listener.ToString(); break; case "InfoWindowClose": js = string.Format ("alert('{0}: {1} - {2} - {3}')", e.eventName, e.point, e.eventArgs[0], DateTime.Now); break; } return(js); }
protected string GMap1_Click(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, string.Format(@"<b>GLatLngBounds</b><br />SW = {0}<br/>NE = {1}", e.bounds.getSouthWest().ToString(), e.bounds.getNorthEast().ToString()) , true); return(window.ToString(e.map)); }
protected string GMap1_Click(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, string.Format(@"<b>GLatLngBounds</b><br />SW = {0}<br/>NE = {1}", e.bounds.getSouthWest().ToString(), e.bounds.getNorthEast().ToString()) , true); return window.ToString(e.map); }
protected string GMap1_Click(object s, GAjaxServerEventArgs e) { string respuesta = string.Empty; Punto pun = new Punto(); pun.longitud = e.point.lng.ToString(); pun.latitud = e.point.lat.ToString(); listaPunto.Add(pun); Session["listaPunto"] = listaPunto; if (DropDownList1.SelectedValue == "Punto") { GIcon icon = new GIcon(); icon.image = "https://www.google.es/maps/vt/icon/name=icons/spotlight/spotlight-poi-medium.png&scale=2?scale=1"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; GMarkerOptions mOpts = new GMarkerOptions(); mOpts.clickable = true; mOpts.icon = icon; GMarker marker = new GMarker(e.point, mOpts); GInfoWindow window = new GInfoWindow(marker, string.Format( @"<b>Longitud y Latitud del Punto</b><br />SW = {0}<br/>NE = {1} <br /> LatLogn{2}", e.bounds.getSouthWest(), e.bounds.getNorthEast(), e.point ), true); txtNombre.Focus(); txtLatitud.Text = e.point.lat.ToString(); txtLongitud.Text = e.point.lng.ToString(); txtNombre.Text = string.Empty; btnInsertar.Enabled = true; btnLimpiar.Enabled = true; respuesta = window.ToString(e.map); } if (DropDownList1.SelectedValue == "Linea" && listaPunto.Count > 1) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, string.Format( @"<b>Longitud y Latitud del Punto</b><br />SW = {0}<br/>NE = {1} <br /> LatLogn{2}", e.bounds.getSouthWest(), e.bounds.getNorthEast(), e.point ), true); respuesta = window.ToString(e.map); } return(respuesta); }
protected string OnGoogleMapClick(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, string.Format( @"<b>GLatLngBounds</b><br/>NE = {0}", e.bounds.getNorthEast()), true); this.coordinates = e.bounds.getNorthEast().ToString().Split(','); return(window.ToString(e.map)); }
protected string OnGoogleMapClick(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, string.Format( @"<b>GLatLngBounds</b><br/>NE = {0}", e.bounds.getNorthEast()), true); this.coordinates = e.bounds.getNorthEast().ToString().Split(','); return window.ToString(e.map); }
protected string GMap1_Click(object s, GAjaxServerEventArgs e) { inverseGeocodingManager igeoManager = new inverseGeocodingManager(e.point, "es"); inverseGeocoding iGeos = igeoManager.inverseGeoCodeRequest(); geoName geo; if (iGeos.geonames.Count > 0) { geo = iGeos.geonames[0]; StringBuilder sb = new StringBuilder(); sb.Append("<div align=\"left\">"); sb.Append("<b>Nearest Place</b>"); sb.Append("<br />"); sb.AppendFormat("Place name: <i>{0}</i> ", geo.name); sb.Append("<br />"); sb.AppendFormat("Point: <i>{0}</i>", geo.nearestPlacePoint.ToString()); sb.Append("<br />"); sb.AppendFormat("Elevation: <i>{0}</i>", geo.nearestPlaceElevation > -9000 ? geo.nearestPlaceElevation.ToString() : "No info"); sb.Append("<br />"); sb.AppendFormat("Country Name (Code): <i>{0} ({1})</i>", geo.countryName, geo.countryCode); sb.Append("<br />"); sb.AppendFormat("Click point - Nearest Place distance (Km): <i>{0}</i>", Math.Round(geo.distance, 3)); sb.Append("</div>"); sb.Append("<br />"); sb.Append("<div align=\"left\">"); sb.Append("<b>Click point</b>"); sb.Append("<br />"); sb.AppendFormat("Point: <i>{0}</i>", geo.initialPoint.ToString()); sb.Append("<br />"); sb.AppendFormat("Elevation: <i>{0}</i>", geo.initialPointElevation > -9000 ? geo.initialPointElevation.ToString() : "No info"); sb.Append("<br />"); sb.Append("</div>"); GInfoWindow window = new GInfoWindow(e.point, sb.ToString(), true); return(window.ToString(e.map)); } else { return(string.Empty); } }
protected string GetInverseGeoCode(GLatLng FromPoint, out string addr) { string streetNumber; string streetName; string locality; string postalCode; string _addr = Geocoder.NearestAddressGoogle(FromPoint.ToString(), out streetNumber, out streetName, out locality, out postalCode); if (_addr != String.Empty) { GInfoWindow window = new GInfoWindow(FromPoint, _addr, true); addr = _addr; return(window.ToString(locationGMap.GMap_Id)); } else { addr = String.Empty; } return(string.Empty); }
protected string GMap1_Click(object s, GAjaxServerEventArgs e) { inverseGeocodingManager igeoManager = new inverseGeocodingManager(e.point, "es"); inverseGeocoding iGeos = igeoManager.inverseGeoCodeRequest(); geoName geo; if (iGeos.geonames.Count > 0) { geo = iGeos.geonames[0]; StringBuilder sb = new StringBuilder(); sb.Append("<div align=\"left\">"); sb.Append("<b>Nearest Place</b>"); sb.Append("<br />"); sb.AppendFormat("Place name: <i>{0}</i> ", geo.name); sb.Append("<br />"); sb.AppendFormat("Point: <i>{0}</i>", geo.nearestPlacePoint.ToString()); sb.Append("<br />"); sb.AppendFormat("Elevation: <i>{0}</i>", geo.nearestPlaceElevation > -9000 ? geo.nearestPlaceElevation.ToString() : "No info"); sb.Append("<br />"); sb.AppendFormat("Country Name (Code): <i>{0} ({1})</i>", geo.countryName, geo.countryCode); sb.Append("<br />"); sb.AppendFormat("Click point - Nearest Place distance (Km): <i>{0}</i>", Math.Round(geo.distance, 3)); sb.Append("</div>"); sb.Append("<br />"); sb.Append("<div align=\"left\">"); sb.Append("<b>Click point</b>"); sb.Append("<br />"); sb.AppendFormat("Point: <i>{0}</i>", geo.initialPoint.ToString()); sb.Append("<br />"); sb.AppendFormat("Elevation: <i>{0}</i>", geo.initialPointElevation > -9000 ? geo.initialPointElevation.ToString() : "No info"); sb.Append("<br />"); sb.Append("</div>"); GInfoWindow window = new GInfoWindow(e.point, sb.ToString(), true); return window.ToString(e.map); } else return string.Empty; }
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); }
protected string GMap1_DragStart(object s, GAjaxServerEventArgs e) { GMarker marker = new GMarker(e.point); GInfoWindow window = new GInfoWindow(marker, "DragStart - " + DateTime.Now.ToString(), false); return window.ToString(e.map); }