加载OpenLayers功能而不加载和显示整个周围的地图

时间:2014-09-30 11:33:28

标签: javascript openlayers

 var config = {
    geoserver: "http://url/geoserver/",
    wms_layer: "tt/wms?service=WMS",
    wfs_layer: "tt/wfs",
    featureNS: "url2",
    init_center : new OpenLayers.Bounds(363273.29099999997,5770864.300999998),
    init_zoom : 4,
    maxExtent:  new OpenLayers.Bounds(363052,5770362,363467,5771122)
}; 

map = new OpenLayers.Map({
  div:"map",
  //zoom:0,
  projection: new OpenLayers.Projection(epsg),
  units: "m",
  maxResolution: 2,
  maxExtent: config.maxExtent,
});

var layer_selectable = new OpenLayers.Layer.Vector("WFS", {
  strategies : [new OpenLayers.Strategy.BBOX(),saveStrategy],
  protocol: new OpenLayers.Protocol.WFS({
  url: config.geoserver + config.wfs_layer,
  version: "1.1.0",
  featureType: "ftype",
  featureNS: config.featureNS,
  srsName: epsg
  }),
  renderers: renderer
}); 

function doSomething() {
   var myFeatures = layer_selectable.getFeaturesByAttribute("fid","<?= $fid ?>");
   alert(myFeatures);
}

 layer_selectable.events.register("loadend", layer_selectable,doSomething);
  map.addLayers([layer_selectable]);
  map.setCenter(config.init_center.getCenterLonLat(),config.init_zoom);

我是OpenLayers的新手。我找到了这段代码。我现在想要的是检索&#39; myFeatures&#39;来自网络服务器的数据,无需加载和显示整个地图和图层。有没有一种简单的方法可以做到这一点?

0 个答案:

没有答案