public static string OpenDataGet(string inputValue) { FunctionLib FunctionList = new FunctionLib(); string Result = ""; if (inputValue == "weather") { Result = FunctionList.WeatherDataParse(); } else if (inputValue == "radiation") { Result = FunctionList.radiationInformation(); } else if (inputValue == "uv") { Result = FunctionList.UVInformation(); } else if (inputValue == "ocean") { Result = FunctionList.OceanDataParse(); } else if (inputValue == "air") { Result = FunctionList.AQXInformation(); } else { List <MarkerLocation> MarkerLocationItemList = new List <MarkerLocation>(); string webAddr = "http://protecttw.cloudapp.net/Service1.svc/GetOpenData/" + inputValue + "/" + Guid.NewGuid(); HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(webAddr); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "GET"; HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse(); Stream resStream = response.GetResponseStream(); DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(List <GetSitedata>)); List <GetSitedata> GetData = obj.ReadObject(resStream) as List <GetSitedata>; foreach (var item in GetData) { MarkerLocation MarkerLocationItem = new MarkerLocation(); if (string.IsNullOrEmpty(item.SiteName) == false) { MarkerLocationItem.title = item.SiteName.Replace(@"""", ""); } else { MarkerLocationItem.title = item.SiteType.Replace(@"""", ""); } MarkerLocationItem.lat = double.Parse(item.SiteLatitude); MarkerLocationItem.lng = double.Parse(item.SiteLongitude); MarkerLocationItem.description = item.SiteAddress.Replace(@"""", ""); MarkerLocationItem.icon = ""; MarkerLocationItemList.Add(MarkerLocationItem); } string json = Newtonsoft.Json.JsonConvert.SerializeObject(MarkerLocationItemList); return(json); } return(Result); }
public void BindToTextLayer(EditableTextFlowLayer textLayer) { this.textLayer = textLayer; //check is on the sameline, //or multiple lines // if (IsOnTheSameLine) { EditableTextLine line = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum); //at this line //find start and end point int startColNum = selectionRangeSnapshot.startColumnNum; int endColNum = selectionRangeSnapshot.endColumnNum; int lineHeight = line.ActualLineHeight; _startLocation = new MarkerLocation() { lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(startColNum), line = line }; _stopLocation = new MarkerLocation() { lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(endColNum), line = line }; } else { EditableTextLine startLine = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum); _startLocation = new MarkerLocation() { lineNum = startLine.LineNumber, x_offset = startLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.startColumnNum), line = startLine }; // EditableTextLine endLine = textLayer.GetTextLine(selectionRangeSnapshot.endLineNum); _stopLocation = new MarkerLocation() { lineNum = endLine.LineNumber, x_offset = endLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.endColumnNum), line = endLine }; // } }
protected void TreeViewUser_SelectedNodeChanged(object sender, EventArgs e) { List <MarkerLocation> MarkerLocationItemList = new List <MarkerLocation>(); string GetValue = TreeViewUser.SelectedNode.Value; string[] TreeToken = GetValue.Split('_'); if (TreeToken[0] == "G") { foreach (TreeNode item in TreeViewUser.SelectedNode.ChildNodes) { string[] ChildTreeToken = item.Value.Split('_'); if (string.IsNullOrEmpty(ChildTreeToken[1]) == false && string.IsNullOrEmpty(ChildTreeToken[2]) == false && string.IsNullOrEmpty(ChildTreeToken[3]) == false) { MarkerLocation MarkerLocationItem = new MarkerLocation(); MarkerLocationItem.title = item.Text; MarkerLocationItem.lat = double.Parse(ChildTreeToken[2]); MarkerLocationItem.lng = double.Parse(ChildTreeToken[3]); if (string.IsNullOrEmpty(ChildTreeToken[4]) == false) { MarkerLocationItem.description = ChildTreeToken[4]; } else { MarkerLocationItem.description = "<div><h>" + item.Text + "</h><br/>" + "</div>"; } //MarkerLocationItem.icon = "/Icon/people1.png"; MarkerLocationItemList.Add(MarkerLocationItem); } } if (MarkerLocationItemList.Count() != 0) { string json = Newtonsoft.Json.JsonConvert.SerializeObject(MarkerLocationItemList); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "JustAlert", "GetGoogleMap('" + json + "');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('以下成員未提供所在位置')", true); } } else if (TreeToken[0] == "U") { if (string.IsNullOrEmpty(TreeToken[1]) == false && string.IsNullOrEmpty(TreeToken[2]) == false && string.IsNullOrEmpty(TreeToken[3]) == false) { MarkerLocation MarkerLocationItem = new MarkerLocation(); MarkerLocationItem.title = TreeViewUser.SelectedNode.Text; MarkerLocationItem.lat = double.Parse(TreeToken[2]); MarkerLocationItem.lng = double.Parse(TreeToken[3]); //MarkerLocationItem.description = TreeViewUser.SelectedNode.Text; if (string.IsNullOrEmpty(TreeToken[4]) == false) { MarkerLocationItem.description = TreeToken[4]; } else { MarkerLocationItem.description = "<div><h>" + TreeViewUser.SelectedNode.Text + "</h><br/>" + "</div>"; } //MarkerLocationItem.icon = "/Icon/people1.png"; MarkerLocationItemList.Add(MarkerLocationItem); string json = Newtonsoft.Json.JsonConvert.SerializeObject(MarkerLocationItemList); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "JustAlert", "GetGoogleMap('" + json + "');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('成員未提供所在位置')", true); } } }