2012-04-29 25 views
0

我有這條線的問題, OpenLayers.ProxyHost =「proxy.cgi?url =」;開放圖層GetFeatureInfo代理設置

除了在開放層代碼集中寫入上面的行之外還應該做什麼? 8080和GeoServer的使用本地主機:

我的信息 我請嘗試使用openlayer 2.10 WMSGetFeatureInfo command.I我得到WMS圖像的特徵信息,GeoServer的和Apache,Tomcat的6.0.35.I可以使用本地主機運行Tomcat 8080/GeoServer的。

我是新來的開放層,我看到有關OpenLayers項目的常見問題,但仍無法弄清楚答案。你們的任何答案對我來說都非常有幫助嗎?

感謝您寶貴的時間。

回答

0

此鏈接可能是有用的:Openlayers Proxy path usage

一些認爲的OpenLayers執行的任務(包括WFS請求)要求,因爲在使用XMLHttpRequest發出請求到遠程服務器的JavaScript中限制使用代理腳本。 在設置地圖之前添加特定聲明。

從這裏開始: http://openlayers.org/dev/examples/2

的代碼示例:

/* 
    * Fix for OpenLayers using 900913 for web mercator and AGS using 102113 (it must run before map init) 
    OpenLayers.Layer.WMS.prototype.getFullRequestString = function(newParams,altUrl) { 
     try { 
      var projectionCode=typeof this.options.projection == 'undefined' ? this.map.getProjection() : this.options.projection; 
     } catch(err){ 
      var projectionCode=this.map.getProjection(); 
     } 
     this.params.SRS = projectionCode=="none" ? null : projectionCode; 
     return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,arguments); 
    } 

*/ 

    OpenLayers.ProxyHost = proxyPath; 

    var options = { 
     projection: mercator, //EPSG:3785/900913 
     displayProjection: geographic, //EPSG:4326 
     theme: null, 
     maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34), 
     maxResolution: 156543.0339, 
     units: 'm', 
     controls: [], 
     numZoomLevels: MAX_ZOOM_LEVEL, 
     allOverlays: true 
    }; 
    OpenLayers.Util.DEFAULT_PRECISION = 18; 

    mp = new OpenLayers.Map('map', options); 
    addMaps(); 
    addControls(); 
    mp.addLayers([googlePhysical, googleSatellite, googleStreets, googleHybrid]); 
    //Enabling the preferred layers with a delay of 450 to be able to load the external backgrounds 
    setTimeout(setInitialLayersDiv, 450); 

    if (!mp.getCenter()) { 
     if (document.getElementById('userMapExtent').value != '') { 
      var sExtent = document.getElementById('userMapExtent').value.split(','); 
      mp.zoomToExtent(new OpenLayers.Bounds(sExtent[0], sExtent[1], sExtent[2], sExtent[3]), true); 
     } else { 
      mp.zoomToExtent(europeGoogleExtent); 
     } 
    } 
    J('#google_loading').hide('slow'); 
+0

感謝,這對我來說是非常有幫助 – sacprasanna 2012-05-25 18:33:48