Elleo/qt-osm-map-providers

Embedding api key into the desktop application

berkantay opened this issue · 8 comments

Hi,
My aim is to embed my api key to the application that I developed and show tiles without API KEY REQUIRED. Could you please help me to do that?

Elleo commented

Do you mean you want to do it without setting up an HTTP server? You could try embedding the repository files in a QRC and see if passing a QRC path to the osm.mapping.providersrepository.address property works

Actually I have two steps,

First, user will download the map using the API KEY one that I embed then I will cache those tiles in a specific directory. Then when he/she goes offline program uses that directory using osm.offline.directory plugin parameter

I am able to do the second part BUT all those cached tiles has API KEY REQUIRED tag on it. I want to remove the tag.

I will try it and let you know whether it works or not.

Cheers

Elleo commented

If you're able to set up an HTTP server it sounds like everything you want to do will work fine with the original method I detailed here: https://blog.mikeasoft.com/2020/06/22/qt-qml-maps-using-the-osm-plugin-with-api-keys/

It just directs the Map element to the correct URLs when online to get files using an API key, so the cached files will still be accessible as normal offline (without any watermarks)

So, initiating a local HTTP server and implementing your method should work. Am I correct?

Elleo commented

That'll work, it doesn't have to be a local HTTP server though, it can also be one hosted online (that'd make it simpler for you if you need to change your API key, or mapping provider without needing users to upgrade)

That worked thanks a lot for your time.

cheers mate

Elleo commented

You're welcome!