With OpenLayers, I'm creating layers like ol.layer.VectorTile

var projection_epsg_name = 'EPSG:900913';
var geoserverLayerName = 'teste:map_shape2';

const tileLoadURL= '' + geoserverLayerName + '@' + projection_epsg_name + '@pbf/{z}/{x}/{-y}.pbf';

// const tileLoadURL = ""
// const tileLoadURL = "http://localhost:8081/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=" + geoserverLayerName + "&STYLE=&TILEMATRIX=" + projection_epsg_name + ":{z}&TILEMATRIXSET=" + projection_epsg_name + "&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";

var vectorSource = new ol.source.VectorTile({       
    tilePixelRatio: 1, 
    tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
    format: new ol.format.MVT(),
    url: tileLoadURL,

var vectorTile = new ol.layer.VectorTile({


I need id to perform a query in the database, but I do not have this attribute. My data comes from PostGIS, and GeoServer is configured in such a way that it displays the id. How can I have this attribute using OpenLayers?

enter image description here

  • 2
    You probably need to make either a WFS request to get attributes back or a WMS getFeatureInfo request. There is no need to put an ID in vector tile vector so GeoServer doesn't – Ian Turton Jan 28 '20 at 17:03
  • 1
    Strictly you don't have any features in a TMS, so difficult to see how you can fetch an id for them. – nmtoken Jan 28 '20 at 17:16
  • to use TMS, I installed the Vector Tile extension and followed the tutorial on that link: docs.geoserver.org/latest/en/user/extensions/vectortiles/… – Marcos Rodrigues Jan 28 '20 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.