Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers 如何从source.XYZ和source.VectorTile获取相同的坐标_Openlayers - Fatal编程技术网

Openlayers 如何从source.XYZ和source.VectorTile获取相同的坐标

Openlayers 如何从source.XYZ和source.VectorTile获取相同的坐标,openlayers,Openlayers,我的地图有两个层,一个是XYZ平铺层,另一个是矢量平铺层。让我困惑的是,这两个层的格式化url中填充了不同的x、y、z参数,我如何才能使它们相同。代码如下: const map = new Map({ target: 'map', layers: [ new TileLayer({ title: "Google Satellite", source: new XYZ({ url: 'http://mt1.google.cn/vt/lyrs=s&hl

我的地图有两个层,一个是XYZ平铺层,另一个是矢量平铺层。让我困惑的是,这两个层的格式化url中填充了不同的x、y、z参数,我如何才能使它们相同。代码如下:

const map = new Map({
target: 'map',
layers: [
    new TileLayer({
        title: "Google Satellite",
        source: new XYZ({ url: 'http://mt1.google.cn/vt/lyrs=s&hl=pl&&x={x}&y={y}&z={z}' }),
    }),
    new VectorTileLayer({
        style:styleFunction,
        source: new VectorTileSource({
            url: 'http://localhost/features?x={x}&y={y}&z={z}',
            format: new GeoJSON({
                featureProjection:"EPSG:4326",
                extractStyles: false,
            }),
            minZoom: 13,
            maxZoom: 13,
        }),
    }),
],
view: new View({
    projection: 'EPSG:4326',
    center: [130.78267,16.065669],
    minZoom:13,
    zoom: 13
})

}))

按如下所示更正视图投影并最终工作

view: new View({
    center: transform([130.78267,16.065669],'EPSG:4326','EPSG:3857'),
    minZoom:13,
    zoom: 13
})