What Is Nearby
This example demonstrates how to create a Flutter app that shows nearby landmarks based on the user’s current position using the Maps SDK for Flutter.
How It Works
This example app demonstrates the following features:
- Obtain location permissions and show a map centered on the user’s location.
- Display nearby landmarks as a list.
- Allow navigation to a detail page displaying information about nearby landmarks.
Map Display and Permissions
The map is displayed and initialized within the MyHomePage widget, which also handles location permissions for Android and iOS. This widget handles the UI, setting up the map and app bar, and uses permission_handler for requesting location permissions.
Fetching Nearby Locations
The WhatIsNearbyPage widget displays a list of nearby landmarks based on the user’s current position. This code searches for nearby landmarks, displaying the results in a ListView.
Displaying Landmark Information
Each nearby landmark is displayed in a list tile showing the name and distance from the current position. This component formats and displays the name and distance of each landmark.