专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > GIS

wfs例子上的有关问题

发布时间:2010-06-06 17:16:42 文章来源:www.iduyao.cn 采编人员:星星草
wfs例子上的问题
在 http://openlayers.org/dev/examples/wfs-states.html (官网例子)中可用看到橙黄色的美国States图层覆盖在上面,我把openlayers官网里的 wfs美国领土states例子下到自己的电脑上,当然是html和js文件都下了,但是在自己的机子上却只能看见底图(http://labs.metacarta.com/wms-c/Basic.py 的basic图层)。

下面是两段源码:
wfs-states.js代码:
var map;
OpenLayers.ProxyHost = "proxy.cgi?url=";

function init() {
  map = new OpenLayers.Map("map");

  var base = new OpenLayers.Layer.WMS("OpenLayers WMS",
  "http://labs.metacarta.com/wms-c/Basic.py",
  {layers: "basic"} 
  );
  map.addLayer(base);

  var wfs = new OpenLayers.Layer.Vector("States", {
  strategies: [new OpenLayers.Strategy.BBOX()],
  protocol: new OpenLayers.Protocol.WFS({
  url: "http://demo.opengeo.org/geoserver/wfs",
  featureType: "states",
  featureNS: "http://www.openplans.org/topp"
  })
  });
  map.addLayer(wfs);

  map.zoomToExtent(new OpenLayers.Bounds(-140.4, 25.1, -44.4, 50.5));
}

wfs-states.html代码:
<html>
  <head>
  <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
  <link rel="stylesheet" href="style.css" type="text/css" />
  <title>WFS: United States (GeoServer)</title>
  <script src="../OpenLayers.js"></script>
  <script src="wfs-states.js"></script>
  </head>

  <body onload="init()">
  <h1 id="title">WFS United States (GeoServer) Example</h1>
  <div id="tags"></div>
  <p id="shortdesc">
  Shows the use of the WFS United States (GeoServer). 
  </p>
  <div id="map" class="smallmap"></div>
  <div id="docs">
  <p>

  This example shows the basic use of a vector layer with the
  WFS protocol.
  </p>
  <p>
  See the <a href="wfs-states.js" target="_blank">wfs-states.js
  source</a> to see how this is done.
  </p> 
  </div>
  </body>
</html>

文件放置的目录应该是没错的……大家有遇见这种情况的吗?
本地显示[/align]

------解决方案--------------------
javascript有cross domain security限制,你没有配置跨域访问,就无法通过js代码用wfs查询的方式访问远程服务器的地图属性信息。
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: