gpt4 book ai didi

android - Flutter如何在圆圈中显示标记? flutter_map

转载 作者:行者123 更新时间:2023-12-03 02:48:02 26 4
gpt4 key购买 nike

Flutter 新手。如何在 flutter_map 的圆圈中显示标记。哪一天已经在尝试解决这个问题。我不能改变半径中的标记,或者只是改变颜色。这就是我所取得的成就:

Position _currentPosition;
static final List<LatLng> _points = [
LatLng(55.749122, 37.659750),
LatLng(55.770854, 37.626963),
LatLng(55.776937, 37.637949),
LatLng(55.739266, 37.637434),
];

static const _markerSize = 40.0;
List<Marker> _markers;
List<CircleMarker> circle;

@override
void initState() {
super.initState();

_markers = _points
.map(
(LatLng point) => Marker(
point: point,
width: _markerSize,
height: _markerSize,
builder: (_) => Icon(Icons.location_on, size: _markerSize),
),
).toList();

_getCurrentLocation();
}

_getCurrentLocation() {
geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.best)
.then((Position position) {
setState(() {
_currentPosition = position;
});

}).catchError((e) {
print(e);
});
}

@override
Widget build(BuildContext context) {
return FlutterMap(
options: new MapOptions(
minZoom: 16.0,
center: new LatLng(_currentPosition.latitude,_currentPosition.longitude)),
layers: [new TileLayerOptions(urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a','b','c']),
new MarkerLayerOptions(
markers: [
new Marker(
width: 45.0,
height: 45.0,
point: new LatLng(_currentPosition.latitude,_currentPosition.longitude),
builder: (context)=>new Container(
child: IconButton(icon: Icon(Icons.accessibility), onPressed: () {print('Marker tapped!');}),
))]),
MarkerLayerOptions(markers: _markers),
CircleLayerOptions(circles: [ CircleMarker(
point: LatLng(_currentPosition.latitude,_currentPosition.longitude),
color: Colors.blue.withOpacity(0.7),
borderStrokeWidth: 2,
useRadiusInMeter: true,
radius: 2000 // 2000 meters | 2 km
)]),
],
);
}

my result - (this is image)
如何更改蓝色圆圈中的标记。例如更改标记图标?

最佳答案

您是否尝试过更改标记的构建器,例如:

_markers = _points
.map(
(LatLng point) => Marker(
point: point,
width: _markerSize,
height: _markerSize,
builder: (_) => Icon(
Icons.location_city,
size: _markerSize,
color: Colors.red,
),
),
).toList();

关于android - Flutter如何在圆圈中显示标记? flutter_map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64413797/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com