Commit 8d32716e authored by Yasiru-Deshan's avatar Yasiru-Deshan

Add marker

parent 56a374f9
......@@ -28,14 +28,16 @@
android:resource="@drawable/launch_background"
/>
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDVIdYvuHrcQKg5Nm4NqEkhEJgvT93epXQ"/>
<intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyABS88malpXXr__XRF8OhZWE3m6O9hdjsU"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
......
......@@ -8,7 +8,7 @@ import GoogleMaps
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("AIzaSyDVIdYvuHrcQKg5Nm4NqEkhEJgvT93epXQ")
GMSServices.provideAPIKey("AIzaSyABS88malpXXr__XRF8OhZWE3m6O9hdjsU")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
......
......@@ -31,6 +31,13 @@ class MapSampleState extends State<MapSample> {
zoom: 14.4746,
);
static const Marker _kGooglePlexMarker = Marker(
markerId: MarkerId('_kGooglePlex'),
infoWindow: InfoWindow(title:"Google Plex"),
icon: BitmapDescriptor.defaultMarker,
position: LatLng(37.42796133580664, -122.085749655962),
);
static const CameraPosition _kLake = CameraPosition(
bearing: 192.8334901395799,
target: LatLng(37.43296265331129, -122.08832357078792),
......@@ -41,7 +48,8 @@ class MapSampleState extends State<MapSample> {
Widget build(BuildContext context) {
return Scaffold(
body: GoogleMap(
mapType: MapType.hybrid,
mapType: MapType.normal,
markers: {_kGooglePlexMarker},
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
......@@ -59,4 +67,107 @@ class MapSampleState extends State<MapSample> {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
}
\ No newline at end of file
}
/*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({AIzaSyDVIdYvuHrcQKg5Nm4NqEkhEJgvT93epXQ});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late GoogleMapController mapController;
final LatLng _center = const LatLng(45.521563, -122.677433);
void _onMapCreated(GoogleMapController controller) {
mapController = controller;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Maps Sample App'),
backgroundColor: Colors.green[700],
),
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 11.0,
),
),
),
);
}
}*/
/*import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
GoogleMapController myMapController;
final Set<Marker> _markers = new Set();
static const LatLng _mainLocation = const LatLng(25.69893, 32.6421);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Maps With Marker'),
backgroundColor: Colors.blue[900],
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: _mainLocation,
zoom: 10.0,
),
markers: this.myMarker(),
mapType: MapType.normal,
onMapCreated: (controller) {
setState(() {
myMapController = controller;
});
},
),
),
],
)));
}
Set<Marker> myMarker() {
setState(() {
_markers.add(Marker(
// This marker id can be anything that uniquely identifies each marker.
markerId: MarkerId(_mainLocation.toString()),
position: _mainLocation,
infoWindow: InfoWindow(
title: 'Historical City',
snippet: '5 Star Rating',
),
icon: BitmapDescriptor.defaultMarker,
));
});
return _markers;
}
}*/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment