I'm trying to use the approach described in this question, but instead of using jQuery to perform the ajax request, I'm using angularJS $http method. I've already verified and the features are being loaded into the source of the layer, but nothing is shown.
Here is the definition of the source:
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
});
Is there any incompatibility problems with using angularJS and openlayers?
The problem was the mismatch of the projection of the data in my GeoJSON (EPSG:4326) and of the map (OpenLayers3 default, EPSG:3857).
To solve the problem, I changed the projection of the data that I was using to build the GeoJSON to EPSG:3857. Since the data was stored in a postGis database, I used the function ST_Transform to change the projection of the geom column contaning the objects.