Skip to content

Commit

Permalink
Fetch marker positons from API
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong1120 committed Jan 10, 2024
1 parent aba7c0a commit ef2eb57
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/screens/map/home_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ class _HomeMapPageState extends State<HomeMapPage> {
if (response.statusCode == 200) {
List<dynamic> data = json.decode(response.body);

setState(() {
_markers.clear();
setState(() {
_markers.clear();
for (var markerData in data) {
final marker = Marker(
final marker = Marker(
markerId: MarkerId(markerData['title'] ?? 'Unknown'), // 使用 'Unknown' 作為後備值
position: LatLng(markerData['lat'], markerData['lng']),
infoWindow: InfoWindow(
position: LatLng(markerData['lat'], markerData['lng']),
infoWindow: InfoWindow(
title: markerData['title'] ?? 'Unknown', // 同上
snippet: '點擊查看詳情',
),
);
_markers.add(marker);
}
});
snippet: '點擊查看詳情',
),
);
_markers.add(marker);
}
});
} else {
logger.e('Failed to load markers. Status code: ${response.statusCode}');
}
Expand Down

0 comments on commit ef2eb57

Please sign in to comment.