,可以通过以下步骤实现:
dependencies:
flutter:
sdk: flutter
google_maps_flutter: ^2.0.10
import 'package:google_maps_flutter/google_maps_flutter.dart';
GoogleMapController? _controller;
Set<Marker> _markers = {};
GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(37.4219999, -122.0840575),
zoom: 10,
),
onMapCreated: (GoogleMapController controller) {
_controller = controller;
},
markers: _markers,
)
void _onMapCreated(GoogleMapController controller) {
_controller = controller;
_markers.add(
Marker(
markerId: MarkerId('marker1'),
position: LatLng(37.4219999, -122.0840575),
infoWindow: InfoWindow(
title: 'Marker 1',
snippet: 'This is marker 1',
),
),
);
_markers.add(
Marker(
markerId: MarkerId('marker2'),
position: LatLng(37.4329999, -122.0740575),
infoWindow: InfoWindow(
title: 'Marker 2',
snippet: 'This is marker 2',
),
),
);
setState(() {});
}
void _addMarker(LatLng position, String title, String snippet) {
_markers.add(
Marker(
markerId: MarkerId(position.toString()),
position: position,
infoWindow: InfoWindow(
title: title,
snippet: snippet,
),
),
);
setState(() {});
}
_addMarker(
LatLng(37.4429999, -122.0640575),
'Marker 3',
'This is marker 3',
);
通过以上步骤,你可以在Google Map中实现折线点的多标记。你可以根据需要添加、删除、更新标记点,并设置标记点的信息窗口。同时,你还可以根据具体的需求,使用Google Map提供的其他功能和属性来定制地图的展示效果。
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云