openLayer/TileLayer/source 需要什么类型的文件?
What type of file does the openLayer/TileLayer/source require?
import { Component, OnInit } from '@angular/core';
import {Map} from'ol';
import TileLayer from 'ol/layer/Tile';
import Stamen from 'ol/source/Stamen';
import View from 'ol/View';
import {transform} from 'ol/proj';
import Zoomify from 'ol/source/Zoomify';
import Projection from 'ol/proj/Projection';
const hongkong = transform([114.15769,22.28552], 'EPSG:4326', 'EPSG:3857');
@Component({
selector: 'app-own-tile',
templateUrl: './own-tile.component.html',
styleUrls: ['./own-tile.component.css']
})
export class OwnTileComponent implements OnInit {
map: Map;
width = 512;
height = 512;
constructor()
{
}
ngOnInit() {
let url = '/assets/jp2';
this.map = new Map({
target: 'map',
layers: [
new TileLayer({
source: url
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
}
}
我的问题是关于 TileLayer 的源部分:源,我需要提供什么样的文件,目前我有一个包含不同光栅图像的文件夹,文件夹名称按以下顺序排列:(缩放级别, x坐标,y坐标)但这给了我错误,错误是:
TypeError: 无法在字符串“/assets/jp2”
上创建 属性 'ol_lm'
为了解决这个错误,我需要我需要在源代码中提供的类型,如果我能对此有所了解,那将会很有帮助。
Layer 对象需要一个来自 OpenLayers 库的 "source" 对象,在您的情况下应该是一个 xyz 源:
import TileLayer from 'ol/layer/Tile'
import XYZSource from 'ol/source/XYZ'
layers: [
new TileLayer({
source: new XYZSource({
url: 'path/to/tiles/{z}/{x}/{y}.[png/jpg/etc]'
})
})
]
import { Component, OnInit } from '@angular/core';
import {Map} from'ol';
import TileLayer from 'ol/layer/Tile';
import Stamen from 'ol/source/Stamen';
import View from 'ol/View';
import {transform} from 'ol/proj';
import Zoomify from 'ol/source/Zoomify';
import Projection from 'ol/proj/Projection';
const hongkong = transform([114.15769,22.28552], 'EPSG:4326', 'EPSG:3857');
@Component({
selector: 'app-own-tile',
templateUrl: './own-tile.component.html',
styleUrls: ['./own-tile.component.css']
})
export class OwnTileComponent implements OnInit {
map: Map;
width = 512;
height = 512;
constructor()
{
}
ngOnInit() {
let url = '/assets/jp2';
this.map = new Map({
target: 'map',
layers: [
new TileLayer({
source: url
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
}
}
我的问题是关于 TileLayer 的源部分:源,我需要提供什么样的文件,目前我有一个包含不同光栅图像的文件夹,文件夹名称按以下顺序排列:(缩放级别, x坐标,y坐标)但这给了我错误,错误是:
TypeError: 无法在字符串“/assets/jp2”
上创建 属性 'ol_lm'为了解决这个错误,我需要我需要在源代码中提供的类型,如果我能对此有所了解,那将会很有帮助。
Layer 对象需要一个来自 OpenLayers 库的 "source" 对象,在您的情况下应该是一个 xyz 源:
import TileLayer from 'ol/layer/Tile'
import XYZSource from 'ol/source/XYZ'
layers: [
new TileLayer({
source: new XYZSource({
url: 'path/to/tiles/{z}/{x}/{y}.[png/jpg/etc]'
})
})
]