Skip to main content
3 of 3
added 2 characters in body
PolyGeo
  • 65.5k
  • 29
  • 115
  • 353

Openlayers displaying local pbf at wrong location

Need help for displaying of local pbf file, it does show tiles but at wrong location and when zoom-in the whole feature set split into 4 locations.

First Openlayers v 4.6.5 is not displaying local pbf file

Here is code i am trying

 new ol.layer.Tile({ source:new ol.source.VectorTile({ format: new ol.format.MVT(), url:"rectangle-1.0.0.pbf" }) }) 

openlayers load file "rectangle-1.0.0.pbf" as i can see in "Network Tab" of Chrome Developer's tool.

try above code with this style code also but shows nothing on map

 style: function(feature, res) { return new ol.style.Style({ stroke: new ol.style.Stroke({ width: 2, color: 'rgba(0, 102, 204)' }) }) }, 

i also try latest openlayers version 5.3.0 but it gives me error "Cannot read property 'ol_uid' of undefined".

Using help from @Mike it now shows pbf tiles with this code

 new ol.layer.VectorTile({ source:new ol.source.VectorTile({ format: new ol.format.MVT(), url:"rectangle-1.0.0.pbf" }) }) 

but at wrong location and when i zoom-in whole feature set split into 4 locations and so on.

Note: Openlayers projection must be 4326 otherwise it does not display pbf files.i am creating pbf files with the help of geojson-vt "https://github.com/mapbox/geojson-vt". (From GeoJSON to pbf).the geojson must be in 4326.

What needs to be done?

zoom-in split features

yasir
  • 123
  • 6