Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部分地图资源存在多域名问题 #2391

Open
liangyuan1 opened this issue Sep 5, 2024 · 6 comments
Open

部分地图资源存在多域名问题 #2391

liangyuan1 opened this issue Sep 5, 2024 · 6 comments
Assignees
Labels

Comments

@jailln
Copy link
Contributor

jailln commented Sep 5, 2024

Can you provide more details about your bug please ?

@liangyuan1
Copy link
Author

liangyuan1 commented Sep 6, 2024

Can you provide more details about your bug please ?

前端代码:vue
具体实现代码addTdMap(view) {
// var projection = getProjection('EPSG:3857')
// var projectionExtent = projection.getExtent()
// var size = getWidth(projectionExtent) / 256
// var resolutions = new Array(19)
// var matrixIds = new Array(19)
// for (var z = 1; z < 20; ++z) {
// resolutions[z] = size / Math.pow(2, z)
// matrixIds[z] = z
// }
//t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}
var orthoSource1 = new itowns.WMTSSource({
url: 'http://t{0-7}.tianditu.gov.cn/img_w/wmts?tk=6e3de5b9cfca24b0f43d7c431acf56b9',
crs: 'EPSG:3857',
name: 'img',
tileMatrixSet: 'w',
format: 'tiles',
style: 'default',
})
var orthoLayer1 = new itowns.ColorLayer('Ortho1', {
source: orthoSource1,
})
view.addLayer(orthoLayer1)
},
结果问题:1、存在跨域,在openlayer和cesium加载不存在跨域问题2、多域名http://t{0-7}.tianditu.gov.cn/img_w/wmts,{0-7}自动转化一个数字,如http://t0.tianditu.gov.cn/img_w/wmts,http://t0.tianditu.gov.cn/img_w/wmts 3、如何自定义切换规则
image

@AnthonyGlt
Copy link
Contributor

Thank you for the issue.
We don't support "dynamic" url. We have some specific case where its handled, for example the google 3d tiles format.
There is also the XYZ that has something similar but depending on what you want to do, maybe it will be easier if you handle it yourself by generating multiple url where you replace {s} and create the layer accordingly.

ALSO, you must type in English so it makes it easier for everyone involved in this project ( english isn't my primary language neither ;) )

@jailln
Copy link
Contributor

jailln commented Sep 10, 2024

@liangyuan1 You can specify subdomains in your url using the following syntax: {u:0|1|2|3|4|5|6|7}

@jailln jailln self-assigned this Oct 14, 2024
@lafflan
Copy link
Contributor

lafflan commented Oct 30, 2024

结果问题:1、存在跨域,在openlayer和cesium加载不存在跨域问题2、多域名http://t{0-7}.tianditu.gov.cn/img_w/wmts,{0-7}自动转化一个数字,如http://t0.tianditu.gov.cn/img_w/wmts,http://t0.tianditu.gov.cn/img_w/wmts 3、如何自定义切换规则

1、我认为这个错误不是itowns的问题,是天地图限制了请求频率,配置多子域名后会好点
2&3、多子域名 http://${u:t0|t1|t2|t3|t4|t5|t6|t7}.tianditu.gov.cn/img_w/wmts,

附:定义token可使用vendorSpecific参数传参,如
WMTSSource({
...
vendorSpecific:{
tk:""
}
}) , 但需要用比较新的版本itowns(≥v2.40.0)

@lafflan
Copy link
Contributor

lafflan commented Oct 30, 2024

@jailln I don't think this is an issue with iTowns, so this issue can be closed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants