瓦片地图加载框架——TiledMapView

有幸参与过一个简易地理信息系统(GIS)的开发,学到了很多地理信息相关的知识,便想要开发一个关于瓦片地图加载的开源库,跟你们一块儿分享交流。java

TiledMapView

Android瓦片地图加载,支持多种投影,包括Web墨卡托投影,经纬度直投及自定义投影等;支持定位,添加图层和覆盖物。android

googlemap

tianditu

用法

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
 
dependencies {
    compile 'com.github.1993hzw:TiledMapView:1.2'
}
复制代码

最新版本请查看>>>TiledMapViewgit

TiledMapView使用Picasso库做为默认图像加载程序。所以,若是你想使用Picasso,应该额外增长依赖:github

dependencies {
    implementation 'com.squareup.picasso:picasso:2.71828'
}
复制代码

代码

在布局里添加TiledMapView:app

<cn.forward.tiledmapview.TiledMapView android:id="@+id/mapview" android:layout_width="match_parent" android:layout_height="match_parent" />
复制代码
TiledMapView mapView = (TiledMapView)findViewById(R.id.mapview);
复制代码

如今你能够添加瓦片图层。以加载谷歌地图为例:maven

TiledMapView mapView = (TiledMapView) findViewById(R.id.mapview);
ITileLayer googleTileLayer = new GoogleTileLayer(mMapView, GoogleOnlineTileImageSource.ImgType.SATILLITE_WITH_MARKER);
mapView.getLayerGroup().add(googleTileLayer);
复制代码

目前,TiledMapView直接支持加载谷歌地图(GoogleTileLayer),天地图(TiandituTileLayer),以及自定义瓦片地图。布局

另外,你也能够添加覆盖物:gradle

TextPixelOverlay textPixelOverlay = new TextPixelOverlay("Hello world!");
textPixelOverlay.setBackgroundColor(0x99ffffff);
textPixelOverlay.getTextPaint().setColor(Color.BLUE);
textPixelOverlay.getTextPaint().setTextSize(Util.dp2px(getApplicationContext(), 14));
textPixelOverlay.setLocationOnMap(0,-300);
mapView.getLayerGroup().add(textPixelOverlay);
复制代码

能够经过使用BitmapPixelOverlay/BitmapMapOverlay添加图片覆盖物google

拓展

这里有一个加载LOL游戏地图的示例,显示了如何加载自定义瓦片地图.url

lol

TiledMapView是一个功能强大、可定制和可扩展的加载库。未来会提供更多的文档,固然,如今您能够经过阅读代码来找到更多的特性,尽情探索吧!

项目地址TiledMapView

最新代码请关注github项目>>>TiledMapView,谢谢你们支持!

相关文章
相关标签/搜索