import io.openmobilemaps.mapscore.map.MapView
import io.openmobilemaps.mapscore.map.MapConfig
import io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemFactory
import io.openmobilemaps.mapscore.shared.map.coordinates.CoordinateSystemIdentifiers
import io.openmobilemaps.mapscore.shared.map.coordinates.Coord
import io.openmobilemaps.mapscore.shared.map.layers.tiled.raster.TiledRasterLayer
import io.openmobilemaps.mapscore.MapsCore
class MainActivity : AppCompatActivity() {
private lateinit var mapView: MapView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize the library
MapsCore.initialize()
// Get reference to MapView from layout
mapView = findViewById(R.id.mapView)
// Setup map with EPSG:3857 coordinate system (Web Mercator)
mapView.setupMap(MapConfig(CoordinateSystemFactory.getEpsg3857System()))
mapView.registerLifecycle(lifecycle)
// Create tiled raster layer with OpenStreetMap tiles
val tiledRasterLayer = TiledRasterLayer()
// Add layer to map
mapView.addLayer(tiledRasterLayer)
// Move camera to initial position (Switzerland)
mapView.getCamera().moveToCenterPositionZoom(
Coord(CoordinateSystemIdentifiers.EPSG4326(), 8.378232525377973, 46.962592372639634, 0.0),
10000000.0,
false
)
}
}