简体   繁体   English

栅格图块顶部的矢量图块未在openLayers中显示

[英]Vector tiles on top of raster tiles is not getting displayed in openLayers

I am trying to render vector tiles on top of raster tiles in open layers map version 4.3.3. 我正在尝试在开放图层地图版本4.3.3中的栅格图块上渲染矢量图块。 Both the tiles are getting render but vector tiles is not getting displayed over raster tiles.For example, I have vector tiles for one of the state and want this to display as semi transparent layer on top of raster tiles. 这两个图块都在渲染,但矢量图块没有显示在栅格图块上。例如,我有一种状态的矢量图块,希望将此显示为栅格图块顶部的半透明层。 I have store my vector tiles on S3 bucket and tileLoadFunction fetching those from S3 bucket. 我已将我的矢量图块存储在S3存储桶中,并且tileLoadFunction从S3存储桶中获取了这些矢量图块。 I haven't set any projection. 我没有设定任何投影。 I think tileLoadFunction has some default projection. 我认为tileLoadFunction具有一些默认投影。

Following is my code to display both the tiles: 以下是我的代码,用于显示两个磁贴:

var map = new ol.Map({
    layers: [
        new ol.layer.Tile({
            name: 'Tile',
            type: 'GeoJSON',
            source: new ol.source.XYZ({
                url: 'https://api.tiles.mapbox.com/v4/mapbox.emerald/{z}/{x}/{y}.png?access_token=' + MAPBOX_KEY
            })
        }),

        new ol.layer.VectorTile({
            name: 'VectorTile',
            type: 'MVT',
            source: new ol.source.VectorTile({
                format: new ol.format.MVT(),
                renderMode: 'vector',
                tileGrid: ol.tilegrid.createXYZ({ maxZoom: 14 }),
                url: 'data',
                tileLoadFunction: tileLoadFunction                    
            }),                 
            style: new ol.style.Style({
                fill: new ol.style.Fill({
                    color: 'rgba(0, 0, 0, 0.5)'
                }),
                stroke: new ol.style.Stroke({
                    color: 'white',
                    width: 3
                })
            })
        })
    ],
    target: 'map',
    view: new ol.View({
        center: [-7400327.330457623, 2062576.7712471967],
        maxZoom: 20,
        minzoom: 2,
        zoom: 8       
    })
});

 function tileLoadFunction(tile, url) {
   getSignedUrl(url, function(s3Url) {
   var loader = ol.featureloader.loadFeaturesXhr(s3Url, tile.getFormat(), 
                          tile.onLoad.bind(tile),                                                 
                          tile.onError.bind(tile));
        tile.setLoader(loader);
    }

Can anybody guide, what is missing here to display vector tiles properly as semi-transparent layer over raster tiles? 任何人都可以指导,这里缺少哪些内容才能正确地将矢量图块显示为栅格图块上的半透明层?

Thanks, 谢谢,

Following is a sample project I have done to customize both vector and raster layers as you wish. 以下是我已完成的示例项目,可以根据需要自定义矢量层和栅格层。 Think this will help you to fix your issue. 认为这将帮助您解决问题。

https://github.com/NisalSP9/openlayers https://github.com/NisalSP9/openlayers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM