android mapview自定义图块

| 我需要在地图视图中添加一个自定义基础层。我的理解是,地图图块与Google图块完全相同。它们是以以下格式提供的静态文件:http:///tilecache///.png 例如,http:///tilecache/6/16/26.png是阿拉巴马州佛罗里达州和密西西比州之间的海湾沿岸。 如何使用图块创建覆盖图?     
已邀请:
        osmdroid(如上面的建议)很酷,但是非常大。不久前,我决定使用http://sourceforge.net/projects/libwlocate/-它包含用于显示/滚动/缩放osmdroid等地图的功能,但您可以选择使用OSM,Google Maps或Google卫星视图。 如何使用它的示例可以在http://libwlocate.git.sourceforge.net/git/gitweb.cgi?p=libwlocate/libwlocate;a=blob;f=master/android/LocDemo/src/com/中找到vwp / locdemo / LocDemo.java; h = 5e2134fb7d197258f5f4f6f9021d2fa9ad9f2d9a; hb = HEAD     
        我建议使用osmdroid。您可以扩展OnlineTileSourecBase。
public class YourTileSource extends OnlineTileSourceBase implements IStyledTileSource<Integer> {

public YourTileSource (String aName, string aResourceId,
    int aZoomMinLevel, int aZoomMaxLevel, int aTileSizePixels,
    String aImageFilenameEnding, String aBaseUrl) {
    super(aName, aResourceId, aZoomMinLevel, aZoomMaxLevel, aTileSizePixels,
            aImageFilenameEnding, aBaseUrl);
}

public void setStyle(Integer style) {
    // TODO Auto-generated method stub
}

public void setStyle(String style) {
    // TODO Auto-generated method stub
}

public Integer getStyle() {
    // TODO Auto-generated method stub
    return null;
}

@Override
public String getTileURLString(MapTile aTile) {
    return getBaseUrl() + \"/\" + aTile.getX() + \"/\" + aTile.getY() + \"/\" + aTile.getZoomLevel() + \".png\";
}
} 然后将您的图块源添加到您的mapview中:
TileSourceFactory.addTileSource(new YourTileSource (\"YourTileSource\", null, 1, 20, 256, \".png\", \"http:///tilecache/\"));
mapView.setTileSource(TileSourceFactory.getTileSource(\"YourTileSource\"));
您的mapView必须是org.osmdroid.views.MapView才能正常工作。 OSMdroid类应替换所有的Google Maps类。 首先下载osmdroid-android-3.0.8.jar文件,将其添加到项目中的libs文件夹中,然后通过右键单击>“属性”>“ Java构建路径”>“库”>“添加Jars”,将其添加到项目中。它在libs文件夹中。如果有其他问题,请发表更多问题,我在osmdroid方面经验丰富。     
        对于较新版本的OSMDroid,构造函数的aResourceId参数已删除,最后一个参数aBaseUrl是String []。
public YourTileSource (String aName, 
    int aZoomMinLevel, 
    int aZoomMaxLevel, 
    int aTileSizePixels,
    String aImageFilenameEnding, 
    String[] aBaseUrl) {

    super(aName, 
          aZoomMinLevel, 
          aZoomMaxLevel, 
          aTileSizePixels, 
          aImageFilenameEnding, 
          aBaseUrl);
}
    

要回复问题请先登录注册