简体   繁体   English

Android Mapview缩放级别-自定义图块服务器

[英]Android Mapview Zoom Level - Custom Tile Server

I created an Android Mobile Application which uses OSMDroid Mapview. 我创建了一个使用OSMDroid Mapview的Android移动应用程序。 It loads perfectly fine from zoom levels below 18. However it only rescales and never serves me tiles from 19 and below. 从18以下的缩放级别加载时,它的加载效果非常好。但是,它只会重新缩放,并且永远不会为19和以下的图块提供服务。

I have my own tile server using Mapnik, Renderd, Mod_tile so on and so forth. 我有自己的地图服务器,使用Mapnik,Renderd,Mod_tile等。 I've set my application to use my own tile server too. 我已经将我的应用程序设置为也使用自己的切片服务器。 Using .../osm_tiles/{zoom}/{x}/{y} I know it goes down to level 20, as I've set. 使用... / osm_tiles / {zoom} / {x} / {y},我知道它已经降到了20级。 It simply doesn't serve it to my mobile device. 它根本无法将其提供给我的移动设备。

I notice that after a while, the tiles cached on my mobile phone tends to "mix" with some loaded with the default MAPNIK one. 我注意到,过一会儿,在我的手机上缓存的图块往往会与某些默认MAPNIK加载的图块“混合”。 Which is causing my map to look weird in certain places. 这使我的地图在某些地方看起来很奇怪。

EDIT: Thanks for all who gave me tips and advice. 编辑:感谢所有给我提示和建议的人。 After deleting and re-downloading the tiles, it's no longer mixed! 删除并重新下载磁贴后,它不再是混合的! I didn't see any mixing of names when I looked through my code but I'm pretty sure at some point I must've made the mistake of naming them the same. 查看代码时,我没有看到名称的任何混淆,但是我可以肯定,在某些时候,我一定犯了一个错误的名字命名错误。

It however, still doesn't go below level 18. Here's what I set in my code though: 但是,它仍然没有低于18级。这是我在代码中设置的内容:

ITileSource tileSource;
tileSource = new XYTileSource("custom", ResourceProxy.string.mapnik, 16, 20, 256, ".png", custom);
    TileSourceFactory.addTileSource(tileSource);

The tiles do go down to 20 upon checking, mod_tile serves them when I access it from the web browser. 磁贴在检查后确实下降到20,当我从Web浏览器访问它时,mod_tile会为它们提供服务。 Looking through the Android Monitor (Using Android Studios Preview 4) I see it downloading and fetching tiles at higher levels but as soon as it goes down to 19, all that stops fetching. 浏览Android Monitor(使用Android Studios Preview 4)时,我看到它以较高的级别下载和获取图块,但是当它降到19时,一切都停止了。

A few different things going on here. 这里发生了一些不同的事情。

1) At zoom levels > than the available imagery, osmdroid will scale that last viewed tile (stretch it to make it bigger). 1)在缩放级别>大于可用图像的缩放级别时,osmdroid将缩放最后查看的图块(将其拉伸以使其更大)。 This gives the illusion of zooming in and is generally replaced immediately as the new tiles are loaded. 这给人以放大的感觉,通常在加载新的图块后立即替换。 It's a feature that's used primarily during the animation inbetween zoom levels. 此功能主要在缩放级别之间的动画期间使用。 In this case, you're simply not getting level 19+ tiles. 在这种情况下,您根本不会获得19级以上的图块。 When configuring osmdroid for your app, did you tell it that the map source (ITileSource) supports the higher zoom levels? 在为您的应用配置osmdroid时,您是否告诉过地图源(ITileSource)支持更高的缩放级别? Also, you may want to turn on debugging and watch the logs to see if attempts are made to download the > 18 tiles. 另外,您可能希望打开调试并查看日志,以查看是否尝试下载> 18个磁贴。

2) Have you confirmed that the tile server really does produce tiles at zoom>18? 2)您是否确认图块服务器确实会以zoom> 18的比例生成图块? osmdroid should go up to around 22. It's difficult to test as few map sources provide imagery at that level. osmdroid应该上升到22左右。由于很少有地图源提供该级别的图像,因此很难进行测试。

3) Mixed up tiles. 3)混合瓷砖。 When using custom tile sources, always make sure the tile source "Name" that you tell osmdroid is somewhat unique. 使用自定义切片源时,请始终确保您告诉osmdroid的切片源“名称”有些独特。 If you use "MAPNIK" for bing and "MAPNIK" for mapquest, you'll end up with a mismatch of tiles from both sources when viewing either one. 如果将“ MAPNIK”用于bing,将“ MAPNIK”用于mapquest,则在查看任一源时,两个源的图块将最终不匹配。 The only way to fix it is to clear the tile catch, which is usually /sdcard/osmdroid/tiles/ 修复它的唯一方法是清除磁贴捕获,通常是/ sdcard / osmdroid / tiles /

Firstly, solved the issue of the mixed tiles by deleting and re-downloading the tiles, it's no longer mixed! 首先,通过删除并重新下载磁贴解决了混合磁贴的问题,不再混合了! I didn't see any mixing of names when I looked through my code but I'm pretty sure at some point I must've made the mistake of naming them the same. 查看代码时,我没有看到名称的任何混淆,但是我可以肯定,在某些时候,我一定犯了一个错误的名字命名错误。 Thanks to Spy for pointing it out. 感谢Spy指出。

So just plug in the your android phone, look for the folder named "osmdroid" and delete tiles accordingly. 因此,只需插入您的android手机,查找名为“ osmdroid”的文件夹并相应地删除图块即可。

Next, it seems I had forgotten to add the line 接下来,似乎我忘了添加行

mv.setTileSource(TileSourceFactory.getTileSource("private"));

After creating the source and adding it, I need to also set it on my mapview specifically. 创建源并将其添加后,我还需要专门在mapview上进行设置。 It previously wasn't going past level 18 and downloading tiles because it was using the default OSM tile source! 以前它并没有超过18级并下载图块,因为它使用的是默认的OSM图块源! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM