Android Maps V2上的模糊自定义切片 [英] Blurred custom tiles on Android Maps V2

查看:181
本文介绍了Android Maps V2上的模糊自定义切片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Google Maps V2上显示CustomOverlay。瓷砖的装载如预期的那样工作,唯一的事情是,所示的瓷砖根本不显得尖锐,有些模糊。谷歌没有让我得到一个可用的答案。



我采用了为TileProvider添加经典的256px x 256px瓦片的方法。我设法得到了一个图像为2x(视网膜)的图像源,这使得整个视觉体验更加清晰,但我宁愿不使用这个源,因为数据传输速率高出四倍,因此无法在移动设备上使用设备和较慢的互联网速度。



我提供了两个不同的渲染地图示例(屏幕截图),它们都具有相同的配置(OSM - 256x256拼贴)和提供的TileProviderOsm 。一个在Galaxy Nexus上,另一个在Nexus 5手机上。这两款产品看起来都不像是正确的。



任何想法我可以做什么来防止模糊或增加清晰度?

我的TileProvider如下所示:

  public class TileProviderOsm扩展UrlTileProvider {

private static final String MAP_URL =http://tile.openstreetmap.org/%d/%d/%d.png;

private static int TILE_WIDTH = 256;
private static int TILE_HEIGHT = 256;

public static int MIN_ZOOM = 7;
public static int MAX_ZOOM = 15;

public TileProviderOsm(){
super(TILE_WIDTH,TILE_HEIGHT);

$ b @Override
public synchronized URL getTileUrl(int x,int y,int zoom){

String s = String.format(Locale .US,MAP_URL,zoom,x,y);
URL url = null;
尝试{
url =新网址(s);
} catch(MalformedURLException e){
e.printStackTrace();
}
return url;




$ b $ p
$ b

以下是我将叠加层添加到地图的方法: / p>

  map.addTileOverlay(new TileOverlayOptions()。tileProvider(new TileProviderOsm())); 

以下是一些呈现的Google地图示例:


解决方案

这是地图图块的缩放级别和缩放比例的问题。这似乎是Android的Maps API V2的一个问题。这种行为应该是按照此处所述的: gmaps-api-问题#4840



我通过从WMS请求更大的图块来解决它 - 只需用512x512替换256x256即可。


I want to show a CustomOverlay on a Google Maps V2. The loading of the tiles works as expected, the only thing is, that the shown tiles are not appearing to be sharp at all, kind of blurry. Google did not get me to an usable answer.

I took the approach of adding classical 256px x 256px tiles for the TileProvider. I managed to get a tile source where the images were @2x (retina), which made the whole visual experience much sharper, but I would rather not use this source, as the data transfer rate is four times higher, hence not usable on mobile devices and slow internet speeds.

I included two different examples (screenshots) of the rendered map, both with the same configuration (OSM - 256x256 tiles) and with the provided TileProviderOsm. One is on a Galaxy Nexus and the other on a Nexus 5 phone. Both do not look like they were rendered correctly.

Any idea what I could do to prevent the blurriness or increase the sharpness?

My TileProvider looks like following:

 public class TileProviderOsm extends UrlTileProvider {

    private static final String MAP_URL = "http://tile.openstreetmap.org/%d/%d/%d.png";

    private static int TILE_WIDTH  = 256;
    private static int TILE_HEIGHT = 256;

    public static int MIN_ZOOM = 7;
    public static int MAX_ZOOM = 15;

    public TileProviderOsm() {
        super(TILE_WIDTH, TILE_HEIGHT);
    }

    @Override
    public synchronized URL getTileUrl(int x, int y, int zoom) {

        String s = String.format(Locale.US, MAP_URL, zoom, x, y);
        URL url = null;
        try {
             url = new URL(s);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        return url;
    }
 }

Here's how I add the overlay to the map:

 map.addTileOverlay(new TileOverlayOptions().tileProvider(new TileProviderOsm()));

Here are some examples of the rendered Google Map:

解决方案

It's a problem with the zoom level and scaling of the map tiles. This seems to be a problem with the Maps API V2 for Android. The behavior is supposedly intended as stated here: gmaps-api-issues #4840

I solved it by requesting larger tiles from the WMS - just replace 256x256 with 512x512.

这篇关于Android Maps V2上的模糊自定义切片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆