MapWinGIS具有PrefetchToFolder的功能,可以将切片缓存到指定的文件系统文件夹以供进一步离线使用。此功能完美运行,但如何加载该图块以在受限区域中创建离线地图? 以下是使用PrefetchToFolder的示例:
double y = 39; // latitude, deg.
double x = 140; // longitude, deg.
double span = 5; // deg.
Extents ext = new Extents();
ext.SetBounds(x - span, y - span, 0.0, x + span, y + span, 0.0);
axMap1.Tiles.PrefetchToFolder(ext, 8, 0, @"c:\map1", ".png", StopFunction());
我的编程语言是C#。
以下是一些可以获取但无法加载的代码:
private void btnLoad_Click(object sender, EventArgs e)
{
TileProviders providers = axMap1.Tiles.Providers; ;
int providerId = (int)tkTileProvider.ProviderCustom + 1;
providers.Add(providerId, "MyProvider", @"file:///C|/map1/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 1, 18);
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
axMap1.TileProvider = tkTileProvider.ProviderCustom;
axMap1.Tiles.ProviderId = providerId;
axMap1.Latitude = 39;
axMap1.Longitude = 140;
axMap1.CurrentZoom = 8;
}
private void btnSave_Click(object sender, EventArgs e)
{
double y = 39; // latitude, deg.
double x = 140; // longitude, deg.
double span = 5; // deg.
Extents ext = new Extents();
ext.SetBounds(x - span, y - span, 0.0, x + span, y + span, 0.0);
axMap1.Tiles.PrefetchToFolder(ext,1 , 0, @"c:\map1", ".png", StopFunction());
}
答案 0 :(得分:2)
你应该使用服务器。例如: mapserver
for windows:
1)下载ms4w:http://www.maptools.org/ms4w/index.phtml?page=downloads.html
2)提取根目录(c:/ ms4w)
3)运行/ms4w/apache-install.bat(在命令行或双击它)启动MS4W Apache Web服务器。此文件将Apache安装为Windows服务(称为" Apache Web Server"),以便在重新启动计算机时启动它。执行时,会弹出一个DOS窗口,显示以下消息:
Installing the Apache MS4W Web Server service
The Apache MS4W Web Server service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service
can be started.
The Apache MS4W Web Server service is starting.
The Apache MS4W Web Server service was started successfully.
4)复制平铺文件/ ms4w / Apache / htdocs / maps
5)然后你应该在http://localhost/maps
中看到这些文件平铺文件genaration :
对于这个过程,我使用mapertive。这个程序免费并生成openstreet地图。这是链接:http://maperitive.net/
代码示例:
TileProviders providers = axMap1.Tiles.Providers; ;
int providerId = (int)tkTileProvider.ProviderCustom + 1;
providers.Add(providerId, "MyProvider", "http:/localhost/maps/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 1, 18);
axMap1.Tiles.ProviderId = providerId;
axMap1.CurrentZoom = 8;
result =
答案 1 :(得分:0)
坦克Melih,正如你所说,我检查了所有东西(除了wsg84,我对此一无所知)但仍然看不到地图!这是我的代码:是的,此解决方案有效。请检查提供者添加方法的返回值,如果值为false,则更改+1值并再次尝试或尝试将投影更改为wsg84。也许地图已添加但你没看到因为你的缩放级别所以在代码中添加map.zoomToTileLevel(1)行而不是currentzoom
axMap1.CtlbackColor = Color.Transparent;
TileProviders providers = axMap1.Tiles.Providers;
int providerId = (int)tkTileProvider.ProviderCustom + 100;
//providers.Add(providerId, "Custom TMS provider", "http://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 1, 18);
providers.Add(providerId, "CustomTMSprovider", @"http://localhost/maps/Tiles/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 1, 18);
axMap1.Tiles.ProviderId = providerId;
axMap1.Projection = tkMapProjection.PROJECTION_WGS84;
axMap1.GrabProjectionFromData = true;
axMap1.ZoomBehavior = tkZoomBehavior.zbUseTileLevels;
axMap1.ZoomToTileLevel(2);
如果我更改提供程序一切正常,但此提供程序无法加载地图。 正如我所说,tile local server效果很好。 再次感谢您的努力。
答案 2 :(得分:0)
将您的网址http:/ localhost / ...更改为http://localhost/ ... 你错过了'/'
答案 3 :(得分:-1)
我正在做这个过程而且我无法加载地图,我在map.mbtiles中有来自maperitive但是如何显示它:我必须将我的文件.mbtiles导出到.png? as ..
" http://localhost/maps/Tiles/ {变焦} / {X} / {Y} .PNG"