andreynovikov / trekarta

Simple, responsive map for your trek. You decide how to journey today, not the application!
https://trekarta.info
GNU General Public License v3.0
169 stars 25 forks source link

WMS and WMTS support #182

Open qnga opened 2 years ago

qnga commented 2 years ago

Hello,

I can see in the code that Trekarta supports OnlineTileSources and I'd like to add a custom WMTS (or maybe WMS) service. I feel like I would need to create a new app with an appropriate Content Provider to do that.

Thanks!

qnga commented 2 years ago

I've managed to get my WMTS map basically working with Trekarta. The main limitation I faced was that the provided maps have to be hard-coded into provider's resources. As far as I understand, you can't provide just one WMTS content provider letting the user choosing maps to use in Trekarta.

andreynovikov commented 2 years ago

Do you mean dynamic source? Or any number of sources?

andreynovikov commented 2 years ago

BTW, sounds to be very promising add-on!

andreynovikov commented 2 years ago

@qnga , there are two options:

  1. Rewrite map plugin API to use dynamic content provider for map settings instead of static resources.
  2. Integrate this functionality directly in Trekarta.

This is up to you to decide. I would support any decision.

andreynovikov commented 6 months ago

@qnga I've made amendments to your code. Somehow I omitted that you removed support for min and max zoom. They are required by app logic because different sources have different limits. I've also updated all my map plugins to new API and they work well. So you can consider new API stable. You can look, how I pass zoom limits here (simple) and here (conditionally). I've also restored passing license info (it's optional). It's not used yet but I have to show it to user on map selection.

I plan to release these changes later this month.

qnga commented 6 months ago

Thanks, I got my maps working. Out of curiosity, what can min and max zoom tell you if you don't have minTileCol, maxTileCol, minTileRow and maxTileRow? Maps don't cover the whole world at a given zoom level, so I assumed that we can't predict wether a tile is available anyway.

andreynovikov commented 6 months ago

There are two issues here.

  1. TileLayer has to know maximum available zoom because it uses tiles from previous zoom and rescales them for larger zooms.
  2. The logic is that maps can stack one on another. So zoom is used to sort them in layer stack.
andreynovikov commented 6 months ago

I've published new version containing your amendments. Would you make your plugin publicly available?

qnga commented 6 months ago

Ok! I can push it onto Github if you're interested, but I don't have time to promote it at the moment

andreynovikov commented 6 months ago

It would be great. I would also like to publish it in Google Play. I can later transfer it to your account if you wish.

qnga commented 6 months ago

Actually I've never been clear about what my plugin does! Unfortunately, I found out that WMTS is a quite flexible protocol so it would be hard to automatically add maps from providers I know nothing about. Currently, my plugin supports official outdoor maps from France (no longer works for a while), Spain and UK. I think I can manage to offer the ability to manually add most of maps asking users for WMTS technical details. That won't be within everybody's reach though...

Still interested?

andreynovikov commented 6 months ago

Of course 😀

andreynovikov commented 6 months ago

BTW, are you a native french speaker? May be you can help localize Trekarta?

qnga commented 6 months ago

Yes, I'm native french speaker. I could have a look, though I don't know well most of the app so I may lack translation context.

andreynovikov commented 6 months ago

I have created translation instructions: https://github.com/andreynovikov/trekarta/wiki/Translation There's also a link to online tool for translation.

qnga commented 5 months ago

Okay! I basically rewrote my plugin, it should be presentable in a few weeks.

qnga commented 4 months ago

I'm mostly done: https://github.com/qnga/trekarta-additional-maps

I guess I will need an icon. Any suggestion?

andreynovikov commented 4 months ago

I suggest using the same icon style as other map plugins: https://github.com/andreynovikov/trekarta-online-maps/tree/master/resources

Plugins with hard-coded map sources use map image of the source: https://github.com/andreynovikov/trekarta-online-maps/blob/master/basemap.at/resources/icon.png

You can place "WMS" or some other descriptive test inside blank rectangle.