Tiled map loader for Android, based on the pyramid model, supports a variety of projections, including Web Mercator projection, latitude and longitude projection and custom projection; supports locating, adding layers and overlays.
Android
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.1993hzw:TiledMapView:1.2'
}
TiledMapView uses the library Picasso as the default images loader. So you should add the additional dependence if you want to use the Picasso :
TiledMapView
dependencies {
implementation 'com.squareup.picasso:picasso:2.71828'
}
Add the TiledMapView to your layout.xml:
<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);
Now, you can add a tile layer. For example, you can add the Google tiled map:
现在你可以
TiledMapView mapView = (TiledMapView) findViewById(R.id.mapview);
ITileLayer googleTileLayer = new GoogleTileLayer(mMapView, GoogleOnlineTileImageSource.ImgType.SATILLITE_WITH_MARKER);
mapView.getLayerGroup().add(googleTileLayer);
Currently, Tiled MapView directly supports loading Google maps (GoogleTileLayer), Tianditu maps(TiandituTileLayer), and the custom tiled maps.
Also, you can add some overlays:
另外,你也
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);
You can use BitmapPixelOverlay/BitmapMapOverlay, if you want add a bitmap overlay.
There is a sample of LOL game map which shows how to load the custom tiled map.
这里
TiledMapView is a powerful, customizable and extensible loading library. There will be more documentation in the future, but you can now find more features by reading the code. Just enjoy it!
TiledMapView
The local tiles in this project are generated by tile-cutter. For more information, please go to tile-cutter.
154330138@qq.com hzw19933@gmail.com
Copyright (C) 2019 Ziwei Huang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.