private void GetDataFromXml(IdentifyResult result, string xmlmarkup) { XmlReader reader = XmlReader.Create(new StringReader(xmlmarkup)); int i = -1; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. IDictionary<string,object> featureatts = new Dictionary<string,object>(); while (reader.MoveToNextAttribute()) {// Read the attributes. featureatts.Add(reader.Name,reader.Value); } i+=1; adddataitems(i,result,featureatts); break; case XmlNodeType.Text: break; case XmlNodeType.EndElement: break; } } } public void adddataitems(int i, IdentifyResult result, IDictionary<string,object> featureatts) { if (featureatts.Count > 0) { string title = result.Value.ToString() + "_" + i + " (" + result.LayerName + ")"; IdentifyComboBox.Items.Add(title); _dataItems.Add(new DataItem() { Title = title, Data=featureatts }); } } public void ShowFeatures(List<IdentifyResult> results) { _dataItems = new List<DataItem>(); if (results != null && results.Count > 0) { IdentifyComboBox.Items.Clear(); string htmlreq = ""; string xmlreq = ""; string xmlmarkup = ""; foreach (IdentifyResult result in results) { Graphic feature = result.Feature; if (result.Value.ToString().IndexOf("WMS") >= 0) { htmlreq = feature.Attributes["URL"].ToString(); xmlreq = htmlreq.Replace("INFO_FORMAT=text/html","INFO_FORMAT=text/xml"); xmlmarkup = (string)HtmlPage.Window.Invoke("getfeatureinfo",xmlreq); GetDataFromXml(result,xmlmarkup); } else { string title = result.Value.ToString() + " (" + result.LayerName + ")"; IdentifyComboBox.Items.Add(title); _dataItems.Add(new DataItem() { Title = title, Data=feature.Attributes }); } } IdentifyComboBox.SelectedIndex = 0; } }
function getfeatureinfo(myurl) //for this to work in firefox, enter about:config in the URL bar and change signed.applets.codebase_principal_support to true { var req = false; req = new ajaxRequest(); try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) { alert("Permission could be denied for cross-browser scripting."); } if (req){ } else { } req.open('GET', myurl,false); req.send(); if(req.status == 200) return req.responseText; } function ajaxRequest(){ var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) for (var i=0; i<activexmodes.length; i++){ try{ return new ActiveXObject(activexmodes) } catch(e){ //suppress error } } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc return new XMLHttpRequest() else return false }
foreach (IdentifyResult result in results) { Graphic feature = result.Feature; htmlreq = feature.Attributes["URL"].ToString(); htmlmarkup = (string)HtmlPage.Window.Invoke("getfeatureinfo",htmlreq); string title = result.Value.ToString() + " (" + result.LayerName + ")"; IdentifyComboBox.Items.Add(title); _dataItems.Add(new DataItem() {
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.