Javascript OpenLayers=>;特征为空

Javascript OpenLayers=>;特征为空,javascript,jquery,json,openlayers,geojson,Javascript,Jquery,Json,Openlayers,Geojson,这是我的GeoJSON结果。 但当我加载它时,我在firebug中得到的结果是feature为null。为什么,我的结果有错误吗?JSON中的坐标是用投影WGS84编写的,在代码中我还将externalProjection设置为WGS84。那么为什么我会得到返回“featureisnull”? 我用于管理地图的代码是: $(document).ready(function() { var wgs84 = new OpenLayers.Projection('EPSG:4326'); var la

这是我的GeoJSON结果。 但当我加载它时,我在firebug中得到的结果是feature为null。为什么,我的结果有错误吗?JSON中的坐标是用投影WGS84编写的,在代码中我还将externalProjection设置为WGS84。那么为什么我会得到返回“featureisnull”? 我用于管理地图的代码是:

$(document).ready(function() {
var wgs84 = new OpenLayers.Projection('EPSG:4326');
var layer = null;
var map = new OpenLayers.Map('map',{projection: wgs84});
  layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
    var baseProjection = layer.projection; 
  map.addLayer(layer);
  map.setCenter(new OpenLayers.LonLat(10,10), 4);
  map.events.register("moveend", null, function(){

      if(map.zoom == 10)
      {
        var bounds = map.getExtent();
        console.log(bounds);
        var ne = new OpenLayers.LonLat(bounds.right,bounds.top).transform(map.getProjectionObject(),wgs84);
        var sw = new OpenLayers.LonLat(bounds.left,bounds.bottom).transform(map.getProjectionObject(),wgs84);
        var vectorLayer = new OpenLayers.Layer.Vector();
        map.addLayer(vectorLayer);
        $.getJSON('ajax.php?a=markers&type=json&sw=('+sw.lon+','+sw.lat+')&ne=('+ne.lon+','+ne.lat+')',function(data){
        //$.getJSON('test.json',function(data){
            var geojson_format = new OpenLayers.Format.GeoJSON({
                'externalProjection': wgs84,
                'internalProjection': baseProjection
                });
            vectorLayer.addFeatures(geojson_format.read(data));
        });
        }
    });
});

您的示例OpenLayer代码工作正常,问题在于GeoJSON:您将坐标拼写为“coordinates”