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.shared.map.layers.tiled.vector.TiledVectorLayer
import io.openmobilemaps.mapscore.MapsCore
class Globe3DActivity : AppCompatActivity() {
private lateinit var mapView: MapView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MapsCore.initialize()
mapView = findViewById(R.id.mapView)
// Setup map with EPSG:3857 coordinate system
val mapConfig = MapConfig(CoordinateSystemFactory.getEpsg3857System())
mapView.setupMap(mapConfig)
mapView.registerLifecycle(lifecycle)
// Add vector or raster layer for 3D rendering
val tiledVectorLayer = TiledVectorLayer(
this,
"https://www.sample.org/base-map/style.json"
)
mapView.add(tiledVectorLayer)
// Alternatively, use raster layer:
// val tiledRasterLayer = TiledRasterLayer()
// mapView.addLayer(tiledRasterLayer)
// Set camera to view from higher altitude for globe effect
mapView.getCamera().moveToCenterPositionZoom(
Coord(CoordinateSystemIdentifiers.EPSG4326(), 0.0, 30.0, 0.0),
50000000.0, // Higher zoom value for globe view
false
)
// Set minimum zoom to maintain globe perspective
mapView.getCamera().setMinZoom(20000000.0)
mapView.getCamera().setMaxZoom(300.0)
}
}