finished map markers
This commit is contained in:
parent
ffa0c0ff34
commit
c7a1f130cf
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:flutter_map/plugin_api.dart';
|
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
@ -34,6 +34,13 @@ class _MapScreenState extends State<MapScreen> {
|
||||||
await rootBundle.loadString("assets/data/stations.json");
|
await rootBundle.loadString("assets/data/stations.json");
|
||||||
final data = await json.decode(stationFile);
|
final data = await json.decode(stationFile);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_stations = data["records"];
|
||||||
|
_getMarkers();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getMarkers() async {
|
||||||
List<Marker> markers = [];
|
List<Marker> markers = [];
|
||||||
|
|
||||||
for (var i = 0; i < _stations.length; i++) {
|
for (var i = 0; i < _stations.length; i++) {
|
||||||
|
@ -43,13 +50,13 @@ class _MapScreenState extends State<MapScreen> {
|
||||||
width: 30,
|
width: 30,
|
||||||
point: LatLng(double.tryParse(_stations[i][4].toString()) ?? 0,
|
point: LatLng(double.tryParse(_stations[i][4].toString()) ?? 0,
|
||||||
double.tryParse(_stations[i][5].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(() {
|
setState(() {
|
||||||
_stations = data["records"];
|
|
||||||
_markers = markers;
|
_markers = markers;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -73,11 +80,11 @@ class _MapScreenState extends State<MapScreen> {
|
||||||
onPressed: () => {print("deez")}, child: const Icon(Icons.add)),
|
onPressed: () => {print("deez")}, child: const Icon(Icons.add)),
|
||||||
body: FlutterMap(
|
body: FlutterMap(
|
||||||
options:
|
options:
|
||||||
MapOptions(center: const LatLng(13.736717, 100.523186), zoom: 2.0),
|
MapOptions(center: const LatLng(13.736717, 100.523186), zoom: 10.0),
|
||||||
children: [
|
children: [
|
||||||
TileLayer(
|
TileLayer(
|
||||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
userAgentPackageName: 'net.winscloud,net',
|
//userAgentPackageName: 'net.winscloud.srt',
|
||||||
),
|
),
|
||||||
MarkerLayer(markers: _markers)
|
MarkerLayer(markers: _markers)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue