GetCapabilities In the Hypergraph WMS Service

Source: Internet
Author: User

When I was doing WMS service aggregation, I encountered a problem. The whole process was like this:

1. Use ArcServer to publish a map WMS service,

2. Then, use the client aggregation example-wms demo provided by Hypergraph to input the WMS address of ArcGIS to the address,

3. Click Next. In the displayed layer name, the layers of the Chinese name are garbled.

I checked the relevant page code and js Code, and finally found that the SuperMap. Utility. getXmlHttpRequest () in the js method provided by hypergraphs has a problem.

The source code provided by the Hypergraph is as follows:

/*** Get metadata information */function getCapabilities () {hideElement ("divWMSLayerSettings"); var url = document. getElementById ("txtWMSAddress "). value; var msg = "retrieving metadata information"; msg + = url; document. getElementById ("divMsg "). innerHTML = msg; showElement ("divMsg"); var url = document. getElementById ("txtWMSAddress "). value; if (url & url. trim ()! = "") {If (url. indexOf ("? ")! =-1) {url + = "&";} else {url + = "? ";} Url + =" SERVICE = WMS & VERSION = 1.1.1 & REQUEST = GetCapabilities "; // obtain the metadata var xhr = SuperMap of the SERVICE. utility. getXmlHttpRequest (); url = getContextPath () + "ajaxhandler? Url = "+ escape (url); xhr. open ("GET", url, true); xhr. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded; charset = gb2312"); var handler = onGetCapabilitiesComplete; var errorHandler = onGetCapabilitiesError; xhr. onreadystatechange = function () {if (xhr. readyState = 4) {if (xhr. status = 200) {var xmldoc; if (window. activeXObject) {xmldoc = new ActiveXObject ("microsoft. XMLDOM ");} else if (document. implementation & document. implementation. createDocument) {xmldoc = document. implementation. createDocument ("", "doc", null);} xmldoc. async = false; if (window. activeXObject) {xmldoc. loadXML (xhr. responseText);} else {var parser = new DOMParser (); xmldoc = parser. parseFromString (xhr. responseText, "text/xml");} handler (xhr. responseText) ;}else {errorHandler () ;}} xhr. send (null) ;}else {alert ("WMS service address cannot be blank"); onPre ();}};

Later, I added a getXMLHttpRequest method as follows:

function getXMLHttpRequest(){    var xhr = false;       if(window.XMLHttpRequest){        xhr = new XMLHttpRequest();    }    if(window.ActiveXObject){        xhr = new ActiveXObject("Microsoft.XMLHTTP");    }       return xhr;}

In the original code, change var xhr = SuperMap. Utility. getXmlHttpRequest () to var xhr = getXMLHttpRequest ();
The layers with Chinese names are not garbled. If you have encountered similar problems, try again like me!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.