Skip to main content

Display your first map

Import the maplibre_gl package and use the MapLibreMap widget to display a map.

import 'package:flutter/material.dart';
import 'package:maplibre_gl/maplibre_gl.dart';

class MapScreen extends StatefulWidget {
const MapScreen({super.key});


State createState() => FullMapState();
}

class MapScreenState extends State<MapScreen> {
MapLibreMapController? _mapController;


Widget build(BuildContext context) {
return Scaffold(
body: MapLibreMap(
onMapCreated: (controller) {
// Don't add additional annotations here,
// wait for the onStyleLoadedCallback.
_mapController = controller;
},
initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)),
onStyleLoadedCallback: () {
debugPrint('Map loaded 😎');
},
),
);
}
}

The result should look something like this:

First map