OpenLayers insists on drawing them over null island, what am I getting wrong?
new ol.layer.Vector({
title: 'vector',
visible: true,
source: new ol.source.Vector({
format: new ol.format.GeoJSON({
defaultDataProjection: 'EPSG:27700',
featureProjection: 'EPSG:3857'
}),
url: function(extent) {
return url;
},
strategy: ol.loadingstrategy.bbox,
crossOrigin: 'anonymous'
}),
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#ff9900',
width: 1
})
})
})
Best Answer
Your code does not include a definition for EPSG:27700.
The definition for EPSG:27700 is not known to OpenLayers by default. In OL4, the definition can be set with
new ol.proj.Projection(options)
, but it is not clear to me how to store this new Projection with OL4 (please comment). Another way of setting the definition is using proj4js (both OL3 and OL4). First you need to include proj4js:Then in your javascript, define the projection:
British National Grid (EPSG:27700):
Or (for reference) Dutch Rijksdriehoeksstelsel (EPSG:28992):
Now you can read and reproject the GeoJSON: OL4:
or OL3 (?):