fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.73k stars 860 forks source link

how to load WMTS map #1000

Closed zjyhll closed 2 years ago

zjyhll commented 3 years ago

how to load WMTS map

JaffaKetchup commented 3 years ago

In answer to your question, WMTS is the default one like used in the README.

If you're asking about WMS, you can check out the examples in the examples folder.

zjyhll commented 3 years ago

In answer to your question, WMTS is the default one like used in the README.

If you're asking about WMS, you can check out the examples in the examples folder.

like this, I can not load it: http://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={x}&TILECOL={y}&tk=您的密钥

JaffaKetchup commented 3 years ago

When I visit that URL, I get this response:

{"msg":"非法Key","resolve":"请到API控制台重新申请Key","code":1}

Looks like you need an API key?

zjyhll commented 3 years ago

When I visit that URL, I get this response:

{"msg":"非法Key","resolve":"请到API控制台重新申请Key","code":1}

Looks like you need an API key? here

http://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={x}&TILECOL={y}&tk=3ef974146950ea15a27a2eface83e2ca

zjyhll commented 3 years ago

When I visit that URL, I get this response:

{"msg":"非法Key","resolve":"请到API控制台重新申请Key","code":1}

Looks like you need an API key?

I mean, does it support this format

child: FlutterMap( options: MapOptions( center: LatLng(30.547645, 104.069887), zoom: 1.0, crs: Epsg4326(), plugins: [ MePolylinePlugin(), ], onTap: _collectPoint, ), layers: [ TileLayerOptions( urlTemplate: 'http://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={x}&TILECOL={y}&tk=3ef974146950ea15a27a2eface83e2ca', subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], tileProvider: NonCachingNetworkTileProvider(), ), MePolylineLayerOptions(paintModel: paintModel), ], ),

JaffaKetchup commented 3 years ago

I'm not sure, but I think it should be supported.

Do you get any errors when you use it?

zjyhll commented 3 years ago

I'm not sure, but I think it should be supported.

Do you get any errors when you use it?

type 'Null' is not a subtype of type 'List' in type cast

JaffaKetchup commented 3 years ago

Can you post the full stack trace?

zjyhll commented 3 years ago

Can you post the full stack trace?

image

zjyhll commented 3 years ago

Can you post the full stack trace?

I find this https://github.com/alexandre-melard/leaflet.TileLayer.WMTS Add WMTS layering for leaflet. but it's for leaflet not flutter_map

ibrierley commented 3 years ago

it works for me if I try and grab a tile direct, eg http://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=4&TILEROW=2&TILECOL=2&tk=3ef974146950ea15a27a2eface83e2ca

JaffaKetchup commented 3 years ago

Well I'm not sure about the null error because I can't see that line of code, but 403 Forbidden is from the server, so you'll need to somehow solve that to get the tile.

But, like @ibrierley, I can also get the tile direct.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

zjyhll commented 2 years ago

ok,I've solved  

曾金叶 @.***

 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年9月27日(星期一) 上午9:48 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [fleaflet/flutter_map] how to load WMTS map (#1000)

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

cj0x39e commented 2 years ago

I also had the same problem, because the type of tk is browser,but Flutter's request does not carry the characteristics of the browser, so we can solve it by using a server-side tk

我也遇到了同样的问题,因为使用的 tk 类型是浏览器的,但是 Flutter 的请求并不会携带浏览器的特征,所以我们用服务端类型的 tk 就可以解决。

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity.

pablojimpas commented 2 years ago

This remains an issue for me, using WMTS has some benefits over WMS for visualization purposes as the tiled WMTS is generally faster and acts as a tile cache in front of the WMS service.

JaffaKetchup commented 2 years ago

Hi @pablojimpas. Can you clarify your issue, as I think this was resolved for @zjyhll?

pablojimpas commented 2 years ago

Hi @pablojimpas. Can you clarify your issue, as I think this was resolved for @zjyhll?

I was expecting to use something like WMSTileLayerOptions but for WMTS that instead of using the GetMap request would use the GetTile request, but I realized now that the author of this issue was using a regular TileLayerOptions and that works well as far as I understand.

The only inconvenience it's that it isn't very discoverable that this package supports WMTS and that the urlTemplate can become really long because of having to pass all the WMTS options directly in the string.