angularjs - OpenLayers v3.5.0 map ,使用 bbox 策略从 GeoJSON 加载特征

标签 angularjs openlayers-3

我正在尝试使用 this question 中描述的方法,但我没有使用 jQuery 来执行 ajax 请求,而是使用了 angularJS $http 方法。我已经验证并且正在将功能加载到层的源中,但没有显示任何内容。

这里是源码的定义:

var vectorSource = new ol.source.Vector({
  loader: function(extent, resolution){   
     $http.get(url).success(function(data){

     var formatGeo = new ol.format.GeoJSON();

     var features = formatGeo.readFeatures(data,
       {featureProjection: 'EPSG:4326'});

    vectorSource.addFeatures(features);
    console.log(vectorSource.getFeatures().length);
  })},
    strategy: ol.loadingstrategy.bbox
});

angularJS和openlayers有没有不兼容的问题?

最佳答案

问题是我的 GeoJSON (EPSG:4326) 和 map (OpenLayers3 默认值,EPSG:3857)中的数据投影不匹配。

为了解决这个问题,我将用于构建 GeoJSON 的数据投影更改为 EPSG:3857。由于数据存储在 postGis 数据库中,我使用函数 ST_Transform 更改包含对象的 geom 列的投影。

关于angularjs - OpenLayers v3.5.0 map ,使用 bbox 策略从 GeoJSON 加载特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30735051/

相关文章:

javascript - 使用 ng-annotate 失败

javascript - AngularJS 将变量从自定义指令传递到模板

javascript - Angular 数据绑定(bind) - 与 JavaScript 对象的绑定(bind)应不区分大小写

javascript - Angular 路由入门

internet-explorer-11 - Openlayers 添加了 Internet Explorer 内存问题的功能

javascript - Openlayer3图标鼠标悬停动画

javascript - 使用不同的投影将 OpenLayers 多边形转换为 GeoJSON

css - AngularJS 循环和格式与 ng-repeat 图像和链接文本

javascript - 以编程方式在 Openlayers 中使用 anchor 进行缩放

javascript - Openlayers 你如何设计与你将要绘制的不同的绘制线串