mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.9 KiB
70 lines
1.9 KiB
/*
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
void main() => runApp(const MyApp());
|
|
|
|
class MyApp extends StatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
State<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
late GoogleMapController mapController;
|
|
|
|
final LatLng _center = const LatLng(-33.86, 151.20);
|
|
|
|
void _onMapCreated(GoogleMapController controller) {
|
|
mapController = controller;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Flutter Demo',
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.green,
|
|
useMaterial3: true,
|
|
),
|
|
home: Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Sydney'), backgroundColor: Colors.green[700]),
|
|
body: GoogleMap(
|
|
onMapCreated: _onMapCreated,
|
|
initialCameraPosition: CameraPosition(
|
|
target: _center,
|
|
zoom: 11.0,
|
|
),
|
|
markers: {
|
|
const Marker(
|
|
markerId: MarkerId('Sydney'),
|
|
position: LatLng(-33.86, 151.20),
|
|
infoWindow: InfoWindow(
|
|
title: "Sydney",
|
|
snippet: "Capital of New South Wales",
|
|
),
|
|
)
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|