首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >开放层GetFeatureInfo代理设置

开放层GetFeatureInfo代理设置
EN

Stack Overflow用户
提问于 2012-04-29 04:25:21
回答 1查看 1.7K关注 0票数 0

我对这一行有问题,OpenLayers.ProxyHost = "proxy.cgi?url=";

除了在开放层代码集中写上一行之外,还应该做些什么?

使用WMSGetFeatureInfo命令获取WMS图像的特征信息,使用openlayer 2.10、geoserver和Apache-tomcat-6.0.35。我可以使用localhost:8080运行tomcat,使用localhost运行geoserver :8080/geoserver。

我是新开层,我看到经常被问到的关于OpenLayers项目的问题,但仍然找不出answer.Yours,任何答案对我来说都是非常有帮助的?

谢谢你宝贵的时间。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-25 15:10:11

这个链接可能很有用:Open层代理路径使用

OpenLayers执行的一些任务(包括WFS请求)需要使用代理脚本,因为JavaScript中对向远程服务器发出请求的XMLHTTPRequest的使用有限制。在设置映射之前添加该特定声明。

从这里开始:http://openlayers.org/dev/examples/2

代码示例:

代码语言:javascript
复制
    /*
     * 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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10369669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档