Problem using custom tile provider in VB6

Hello! I’m using the v5.0.1 version of mapwingis.ocx on a VB6 project, and I’m trying to migrate to locally generated tiles.
The project works fine when I’m using openstreetmap tiles. I also have confirmed that my local tile server is working, a leaflet pointed to localhost displays my tiles just fine.
However, when I try to set up mapwingis to use my localhost server as a custom tile provider, no images are displayed.
Here is the code I’m using:

Dim myId As Long
myId = tkTileProvider.ProviderCustom + 1
ans = Map1.Tiles.Providers.Add(myId, "Localhost Provider", "http://localhost/hot/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 18)
Map1.Tiles.providerId = myId
Map1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR

Here is some debugging I did on the immediate window, which seem to indicate that everything is set up correctly as far as I can tell:

?Map1.Tiles.Providers.IndexByProviderId(myId) 17 
?Map1.Tiles.Providers.UrlPattern(17) http://localhost/hot/{zoom}/{x}/{y}.png
?Map1.Tiles.Providers.Name(17) Localhost Provider
?Map1.Tiles.ProviderId 1025 

Is there something that I’m missing? Can anyone give me some hints here? Thanks!

The first thing to try is to set

myId = tkTileProvider.ProviderCustom

getting rid of the + 1.

I ran into some issues with that, and I need to dig deeper if that is actually the issue, because I know that our documentation says to use + 1.

You may also want to set the projection to Google Mercator before adding the tile layer, in case the map tries to reproject your tiles to the current projection (if there is one) and then has to project again to the Google Mercator.

Let me know if that works.

Thanks.
Jerry.

Thank you for your help, Jerry!

I implemented both your suggestions, but the map still won’t show any images.

Something I did notice is that after the program leaves the form load sub, if I query the value of Map1.Tiles.Providers.IndexByProviderId(myId) it returns 0 instead of 17.

EDIT: Some additional info: I installed Visual Studio and did a test trying to use my custom provider in a C# project, and everything worked just fine, so it would seem the problem is exclusive to using the control in VB6. Regrettably, using VB6 is a project requirement right now, so I hope we can find a fix.

EDIT 2: Suddenly, it works! Without any changes to the source code, the control loads my custom tile provider images in the VB6 project. I wonder if it was some dependency that got installed with Visual Studio? It keeps working after a reboot too. I’ll post again with more info if I can reproduce the problem, but for now it seems to have been fixed. We’ll see what happens when I deploy the project in another computer…

EDIT 3: Now when I set my tile provider to OpenStreetMap in the VB6 project, I can’t get images to work… It seems there is some system wide setting that can only be modified when running in Visual C# but not when running in VB6?

EDIT 4: I can switch between the two tile providers when compiling an EXE but it fails when running from inside VB6 in debug mode… This is giving me a headache

Just a quick note. You may already know, but when running from the IDE, some of the file dependencies (DLLs) need to be in the VB6.exe directory (e.g. C:\Program Files (x86)\Microsoft Visual Studio\VB98). This also affects where MapWinGIS puts the tile cache (mwtiles.db3). (We don’t use tiles from our VB6 app, so I don’t have much experience with that).

@pablodaniel Do you still have problems with your custom tile provider?

Hey pmeems!
For now it seems to be working… It has some problems when running from the IDE, but when running the compiled .exe everything seems to work fine.