Hi there👋. I'm SincApp Software Manager. I would be happy to present a part of our SincApp Application with you. In the application, we made a multi-point(📍) display on the map. We share it so that you can integrate it into your applications.
google_maps_flutter: ^2.1.1
maps_launcher: ^2.0.1
you should visit to https://pub.dev/ address to examine.
1 for android ->
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/>
-
Specify your API key in the application delegate ios/Runner/AppDelegate.swift:
import UIKit import Flutter import GoogleMaps @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GMSServices.provideAPIKey("YOUR KEY HERE") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } }
android {
defaultConfig {
minSdkVersion 20
}
}
and STOP your project and rerun it and
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MapMultiMarker extends StatefulWidget {
const MapMultiMarker({Key? key}) : super(key: key);
@override
State<MapMultiMarker> createState() => _MapMultiMarkerState();
}
class _MapMultiMarkerState extends State<MapMultiMarker> {
final List<Map<String, dynamic>> clityList = const [
{
"address": "SincApp_001",
"id": "sincapp001",
"image":
"...",
"lat": 41.087525,
"lng": 28.951964,
"name": "Haliç Üniversitesi-Sincap001",
"postCode": "34060",
"region": "European Side"
},
{
"address": "SincApp_002",
"id": "sincapp002",
"image":
"...",
"lat": 41.087000,
"lng": 28.952001,
"name": "Haliç Üniversitesi-Sincap002",
"phone": "34060",
"region": "European Side"
}
];
final Map<String, Marker> _markers = {};
Future<void> _onMapCreated(GoogleMapController controller) async {
_markers.clear();
setState(() {
for (int i = 0; i < clityList.length; i++) {
print("For Loop");
final marker = Marker(
markerId: MarkerId(clityList[i]['name']),
position: LatLng(clityList[i]['lat'], clityList[i]['lng']),
infoWindow: InfoWindow(
title: clityList[i]['name'],
snippet: clityList[i]['address'],
onTap: () {
print("${clityList[i]['lat']}, ${clityList[i]['lng']}");
}),
onTap: () {
print("Clicked on marker");
},
);
print("${clityList[i]['lat']}, ${clityList[i]['lng']}");
_markers[clityList[i]['name']] = marker;
}
});
}
@override
Widget build(BuildContext context) {
return GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: const CameraPosition(
target: LatLng(clityList[0]['lat'], clityList[0]['lng']),
zoom: 4.8,
),
markers: _markers.values.toSet(),
);
}
}
launchMap(lat, long)
{
MapsLauncher.launchCoordinates(lat, long);
}