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.vector.TiledVectorLayer
import io.openmobilemaps.mapscore.MapsCore
class VectorMapActivity : AppCompatActivity() {
private lateinit var mapView: MapView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize the library
MapsCore.initialize()
// Get reference to MapView
mapView = findViewById(R.id.mapView)
// Setup map with EPSG:3857 coordinate system
mapView.setupMap(MapConfig(CoordinateSystemFactory.getEpsg3857System()))
mapView.registerLifecycle(lifecycle)
// Create vector layer with style URL
val tiledVectorLayer = TiledVectorLayer(
this,
"https://www.sample.org/base-map/style.json"
)
// Add layer to map
mapView.add(tiledVectorLayer)
// Move camera to initial position
mapView.getCamera().moveToCenterPositionZoom(
Coord(CoordinateSystemIdentifiers.EPSG4326(), 8.378232525377973, 46.962592372639634, 0.0),
1000000.0,
false
)
}
}