Custom MapProvider and data is from MapTiler

Topics: Help
Dec 28, 2011 at 9:52 AM

hi guys,

i have created a custom map provider that will load tiles from a local directory. actually the tiles i am using are from a tile directory format output from maptiler. anyone have experienced creating somethign like this?

actually i manage to see that my zoom level and actual (x) is okay, but then when it's trying to load a specific png file, the actual y is not loaded.

btw, i am sure that my path is correct via "<local path>\zoom\x\y.png but apparently the map is looking for a wrong y file? meaning the maptiler didn't create a specific y.png.

sorry i cannot really explain in fully what i am going through, but to explain it short

maptiler doesn't seem to match the actual hierarchy that the current is looking for.

my custom map provider is just inherits from GMapProvider and changed the implementation of GetTileImage to get the images from a local directory.



Dec 28, 2011 at 11:02 AM

actually i can show the maptiles but it's not in the actual y location.

like for example gmap position is y = 523 but in maptiler output its 500 at zoom level 10

any adjustments that i have to make? sorry not familiar really with map projection or anything you may call it...

Jan 9, 2012 at 11:32 AM

custom provider requires custom projection if it's not standart

Jan 20, 2012 at 9:47 AM
Edited Jan 20, 2012 at 9:48 AM

you are right radioman,

that's the problem with "MapTile", it's the same bounds but the indexing is different


If you use the "MapTiler" to create tiles the calculation of coordinates is different.

It's exactly this one for "MapTiler" tiles:


public override PureImage GetTileImage(GPoint pos, int zoom)
         string url = MakeTileImageUrl(pos, zoom, LanguageStr);

         return GetTileImageUsingHttp(url);

string MakeTileImageUrl(GPoint pos, int zoom, string language)
          var x = pos.X;
          // Invert tile y origin from top to bottom of map
          var ymax = 1 << zoom;
          var y = ymax - pos.Y - 1;
          return string.Format(UrlFormat, zoom, x, y);         
static readonly string UrlFormat = "http://localhost/{0}/{1}/{2}.png";