2017-02-22 96 views
3

我一直試圖從osmdroid的geo服務器上獲取WMS Tiles。但迄今爲止沒有成功。我只是設法得到一個位於其他位置的瓷磚地理服務器的小版本。是的投影是正確的,因爲我也爲我的web應用程序使用了同一個圖層。
以下是我的代碼使用osmdroid鏈接Geo服務器

MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext()); 
    XYTileSource tilesource = new XYTileSource("tiger:tiger_roads",0, 18, 256, ".png", new String[]{"http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0"}) { 
@Override 
public String getTileURLString(MapTile aTile) { 
        return getBaseUrl() +"/tiger:tiger_roads/"+aTile.getZoomLevel()+"/"+aTile.getY()+"/"+aTile.getX()+".png"; 

        } 
    }; 
    tileProvider.setTileSource(tilesource); 
    TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this); 
    tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT); 
    map.getOverlays().add(tilesOverlay); 
    map.invalidate(); 
} 

我logcat的產生這是我一直在放大 W/OsmDroid:問題下載MapTile:/ 9 /193分之147HTTP響應:未找到

+3

這是因爲你沒有輸入圖層名稱。試試這個http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0/tiger:tiger_roads/9/147/193.png –

回答

0

您的服務器有這層4頁不同的URL:

<TileMap title="Manhattan (NY) roads" srs="EPSG:4326" profile="global-geodetic" href="http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0/tiger%[email protected]%[email protected]"/> 
<TileMap title="Manhattan (NY) roads" srs="EPSG:4326" profile="global-geodetic" href="http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0/tiger%[email protected]%[email protected]"/> 
<TileMap title="Manhattan (NY) roads" srs="EPSG:900913" profile="global-mercator" href="http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0/tiger%[email protected]%[email protected]"/> 
<TileMap title="Manhattan (NY) roads" srs="EPSG:900913" profile="global-mercator" href="http://dev.propertyninja.com:8080/geoserver/gwc/service/tms/1.0.0/tiger%[email protected]%[email protected]"/> 

這些瓷磚最終太小的事實表明,你正在使用ESPG:4326(latlon),而不是谷歌的Web墨卡託投影(EPSG:900913)。

還有一個問題,即您正在使用XYZTileSource作爲TMS層 - 因此存在一個公平的機會,即Y coordinate is flipped