i am trying to display my own created vector tiles(.pbf), they are not getting displayed with no error on console of inspect element. I am dispaying them by using a simple example html file at: here
I just have changed the url to look for vector tiles on the local server instead of mapbox server.
When i try to display the pbf files from mapbox server: , it gets displayed. Also i have downloaded these mapbox pbf files and served same files from local server they get displayed.
But the pbf files which i have created from geojson file using tippecanoe cant be displayed by openlayers.The generated pbf files are correct as i am able to dislay them using mapbox js script. I have cors on,server's content encoding is also gzip. Sample pbf file which is not getting displayed by the attached code but by tileserver-gl(mapbox script) can be downloaded from here
code:
<!DOCTYPE html>
<html>
<head>
<title>Mapbox Vector Tiles</title>
<link rel="stylesheet"href="https://openlayers.org/en/v4.5.0/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.5.0/build/ol.js"></script>
<script src="https://openlayers.org/en/v4.5.0/examples/resources/mapbox-streets-v6-style.js"></script>
<script src='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.js'></script>
<style>
.map {
background: #f8f4f0;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
var key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiRk1kMWZaSSJ9.E5BkluenyWQMsBLsuByrmg';
var map = new ol.Map({
layers: [
new ol.layer.VectorTile({
declutter: true,
source: new ol.source.VectorTile({
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>',
format: new ol.format.MVT(),
url: 'http://localhost:8000/tippecanoe_tiles/' + '{z}/{x}/{y}.pbf'
//url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
// '{z}/{x}/{y}.vector.pbf?access_token=' + key
}),
style: createMapboxStreetsV6Style(ol.style.Style, ol.style.Fill, ol.style.Stroke, ol.style.Icon, ol.style.Text)
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
</script>
</body>
</html>
You're using OpenLayers 4.5 instead of OpenLayers 5.X, try uploading your OpenLayers version.