diff --git a/lib/pages/map.dart b/lib/pages/map.dart index cd57c81..d2f6a1b 100644 --- a/lib/pages/map.dart +++ b/lib/pages/map.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:flutter_map/plugin_api.dart'; + import 'package:latlong2/latlong.dart'; void main() async { @@ -34,6 +34,13 @@ class _MapScreenState extends State { await rootBundle.loadString("assets/data/stations.json"); final data = await json.decode(stationFile); + setState(() { + _stations = data["records"]; + _getMarkers(); + }); + } + + Future _getMarkers() async { List markers = []; for (var i = 0; i < _stations.length; i++) { @@ -43,13 +50,13 @@ class _MapScreenState extends State { width: 30, point: LatLng(double.tryParse(_stations[i][4].toString()) ?? 0, double.tryParse(_stations[i][5].toString()) ?? 0), - builder: (ctx) => const Icon(Icons.pin_drop), + builder: (ctx) => + const Icon(Icons.pin_drop, color: Colors.brown, size: 50.0), ), ); } setState(() { - _stations = data["records"]; _markers = markers; }); } @@ -73,11 +80,11 @@ class _MapScreenState extends State { onPressed: () => {print("deez")}, child: const Icon(Icons.add)), body: FlutterMap( options: - MapOptions(center: const LatLng(13.736717, 100.523186), zoom: 2.0), + MapOptions(center: const LatLng(13.736717, 100.523186), zoom: 10.0), children: [ TileLayer( urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: 'net.winscloud,net', + //userAgentPackageName: 'net.winscloud.srt', ), MarkerLayer(markers: _markers) ],