Fortunately, I participated in the development of a simple geographic information system (GIS) and learned a lot of knowledge related to geographic information, so I want to develop an open source library about tile map loading and share with you.
TiledMapView
Android tile map loading, support a variety of projections, including Web Mercator projection, latitude and longitude direct projection and custom projection, etc. Support for positioning, adding layers and coverings.
usage
Gradle
allprojects {
repositories{... maven { url'https://jitpack.io'}}}dependencies {
compile 'com. Making. 1993 HZW: TiledMapView: 1.2'
}
Copy the code
See >>>TiledMapView for the latest version
TiledMapView uses the Picasso library as the default image loader. Therefore, if you want to use Picasso, you should add an additional dependency:
dependencies {
implementation 'com. Squareup. Picasso was: Picasso was: 2.71828'
}
Copy the code
code
Add TiledMapView to the layout:
<cn.forward.tiledmapview.TiledMapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Copy the code
TiledMapView mapView = (TiledMapView)findViewById(R.id.mapview);
Copy the code
Now you can add tile layers. Take loading Google Maps as an example:
TiledMapView mapView = (TiledMapView) findViewById(R.id.mapview);
ITileLayer googleTileLayer = new GoogleTileLayer(mMapView, GoogleOnlineTileImageSource.ImgType.SATILLITE_WITH_MARKER);
mapView.getLayerGroup().add(googleTileLayer);
Copy the code
TiledMapView currently supports loading Google Maps, TiandituTileLayer, and custom tile maps directly.
Alternatively, you can add mulch:
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);
Copy the code
By using BitmapPixelOverlay/BitmapMapOverlay add images covering
expand
Here is an example of loading an LOL game map, showing how to load a custom tile map.
TiledMapView is a powerful, customizable and extensible loading library. More documentation will be available in the future, of course, but for now you can read the code to find out more features, so feel free to explore!
The project addressTiledMapView
The latest code please pay attention to github project >>>TiledMapView, thank you for your support!