Skip to main content
GuidesAPI ReferenceExamplesFAQ

Overlapped Maps

Estimated reading time: 2 minutes

This example demonstrates how to create a Flutter application that utilizes the Maps SDK for Flutter to display overlapped maps. The application initializes the GemKit SDK and renders two maps on top of each other, showcasing the ability to layer map views.

How It Works

  • Main App Setup : Sets up the app’s home screen with two maps overlapped.
hello_map
Two overlapped GemMap widgets

UI and Map Integration

The main application consists of a simple user interface that displays two maps stacked on top of each other. The user can see both maps simultaneously, allowing for comparison or overlaying of different data. This code sets up the main application UI, including an app bar and a body that contains a stack of maps.

class MyApp extends StatelessWidget {
const MyApp({super.key});


Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Overlapped Maps',
home: MyHomePage(),
);
}
}

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


State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

void dispose() {
GemKit.release();
super.dispose();
}


Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple[900],
title: const Text('Overlapped Maps', style: TextStyle(color: Colors.white)),
),
// Stack maps
body: Stack(children: [
const GemMap(
key: ValueKey("GemMap"),
appAuthorization: projectApiToken,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.4,
width: MediaQuery.of(context).size.width * 0.4,
child: const GemMap(appAuthorization: projectApiToken),
),
]),
);
}
}

Flutter Examples

Maps SDK for Flutter Examples can be downloaded or cloned with Git.