ManageAccountPage #42
211
lib/Map.dart
211
lib/Map.dart
|
@ -1,9 +1,14 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:flutter_google_places/flutter_google_places.dart';
|
import 'package:flutter_google_places/flutter_google_places.dart';
|
||||||
import 'package:google_maps_webservice/places.dart';
|
import 'package:google_maps_webservice/places.dart';
|
||||||
import 'package:google_api_headers/google_api_headers.dart';
|
import 'package:google_api_headers/google_api_headers.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Map extends StatefulWidget {
|
class Map extends StatefulWidget {
|
||||||
|
@ -15,17 +20,208 @@ const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk";
|
||||||
|
|
||||||
final homeSacffoldKey = GlobalKey<ScaffoldState>();
|
final homeSacffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
List<_Marker> markers = [];
|
||||||
|
|
||||||
|
|
||||||
class MapState extends State<Map> {
|
class MapState extends State<Map> {
|
||||||
|
|
||||||
|
Future getMerkerData() async {
|
||||||
|
var url = Uri.parse('https://openstreetgs.stockholm.se/geoservice/api/b8e20fd7-5654-465e-8976-35b4de902b41/wfs?service=wfs&version=1.1.0&request=GetFeature&typeNames=od_gis:Markupplatelse&srsName=EPSG:4326&outputFormat=json');
|
||||||
|
var response = await http.get(url);
|
||||||
|
|
||||||
|
print('Response status: ${response.statusCode}');
|
||||||
|
// print('Response body: ${response.body.toString()}');
|
||||||
|
var jsonData = jsonDecode(response.body);
|
||||||
|
|
||||||
|
/* print(jsonData['features'][0]);
|
||||||
|
|
||||||
|
print(jsonData['features'][1]['properties']['Plats_1']);
|
||||||
|
|
||||||
|
print(jsonData['features'][0]['properties']['Gatunr_1']);
|
||||||
|
|
||||||
|
print(jsonData['features'][0]['properties']['Kategorityp']);
|
||||||
|
|
||||||
|
/*String data = jsonData['features'][0]['properties']['Kategorityp'];
|
||||||
|
print(data.contains('Tillfälliga bostäder'));*/
|
||||||
|
|
||||||
|
|
||||||
|
print(jsonData['features'][1]['geometry']['coordinates']);*/
|
||||||
|
|
||||||
|
//print(jsonData['features'][0]['properties']['MAIN_ATTRIBUTE_VALUE']);
|
||||||
|
|
||||||
|
// List<_Marker> markers = [];
|
||||||
|
|
||||||
|
for(var m in jsonData['features']) {
|
||||||
|
String data = m['properties']['Kategorityp'];
|
||||||
|
String typ = m['properties']['MAIN_ATTRIBUTE_VALUE'];
|
||||||
|
if(m['properties']['Kategorityp'] == "1.400I, Uteservering A-läge") {
|
||||||
|
print(m['properties']['Kategorityp']);
|
||||||
|
_Marker marker = _Marker(m['properties']['Plats_1'],m['properties']['Gatunr_1'],m['geometry']['coordinates']);
|
||||||
|
markers.add(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
print(markers.length);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var mar in markers) {
|
||||||
|
print(mar.Plats_1);
|
||||||
|
print(mar.Gatunr_1);
|
||||||
|
print(mar.coordinates[1]);
|
||||||
|
print(mar.coordinates[0]);
|
||||||
|
count++;
|
||||||
|
print(count);
|
||||||
|
if (count == 100) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//print(m['properties']['Kategorityp']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Completer<GoogleMapController> _controller = Completer();
|
final Completer<GoogleMapController> _controller = Completer();
|
||||||
|
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
static const CameraPosition _kGooglePlex = CameraPosition(
|
static const CameraPosition _kGooglePlex = CameraPosition(
|
||||||
target: LatLng(55.427320, 13.819257),
|
target: LatLng(59.325027,18.068516),
|
||||||
zoom: 14.4746,
|
zoom: 14.4746,
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<Marker> markersList = {};
|
List<Marker> markersList = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
intilize();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
intilize() {
|
||||||
|
Marker marker_1;
|
||||||
|
//for(var marker in markers) {
|
||||||
|
marker_1 = const Marker(
|
||||||
|
markerId: MarkerId('id_1'),
|
||||||
|
position: LatLng(59.320671571444514, 18.055854162299937),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Münchenbryggeriet Beer Garden',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_2 = const Marker(
|
||||||
|
markerId: MarkerId('id_2'),
|
||||||
|
position: LatLng(59.33115735285231, 18.074432570090742),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Le Hibou',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_3 = const Marker(
|
||||||
|
markerId: MarkerId('id_3'),
|
||||||
|
position: LatLng(59.3315552932853, 18.092751076985277),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Strandbryggan',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_4 = const Marker(
|
||||||
|
markerId: MarkerId('id_4'),
|
||||||
|
position: LatLng(59.33632582609118, 18.072980646196587),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Stureplan 1',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_5 = const Marker(
|
||||||
|
markerId: MarkerId('id_5'),
|
||||||
|
position: LatLng(59.3240158318325, 18.070690101341437),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Bågspännaren Bar & Cafe',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_6 = const Marker(
|
||||||
|
markerId: MarkerId('id_6'),
|
||||||
|
position: LatLng(59.31905195030728, 18.075349015415547),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Mosebacketerrassen',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_7 = const Marker(
|
||||||
|
markerId: MarkerId('id_7'),
|
||||||
|
position: LatLng(59.31583756143469, 18.072591381467536),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Snaps Bar & Bistro',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_8 = const Marker(
|
||||||
|
markerId: MarkerId('id_8'),
|
||||||
|
position: LatLng(59.315129508641505, 18.074243159987006),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Kvarnen',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_9 = const Marker(
|
||||||
|
markerId: MarkerId('id_9'),
|
||||||
|
position: LatLng(59.31533181094423, 18.070972638518455),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Neverland Pub & Restaurang',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_10 = const Marker(
|
||||||
|
markerId: MarkerId('id_10'),
|
||||||
|
position: LatLng(59.31578389646754, 18.071146819010995),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Baras Imperium',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_11 = const Marker(
|
||||||
|
markerId: MarkerId('id_11'),
|
||||||
|
position: LatLng(59.31549103673382, 18.035425964557245),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'YUC Tanto',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Marker marker_12 = const Marker(
|
||||||
|
markerId: MarkerId('id_12'),
|
||||||
|
position: LatLng(59.314826329005506, 18.03317611771755),
|
||||||
|
infoWindow: InfoWindow(
|
||||||
|
title: 'Loopen',
|
||||||
|
snippet: 'Uteservering',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
markersList.add(marker_1);
|
||||||
|
markersList.add(marker_2);
|
||||||
|
markersList.add(marker_3);
|
||||||
|
markersList.add(marker_4);
|
||||||
|
markersList.add(marker_5);
|
||||||
|
markersList.add(marker_6);
|
||||||
|
markersList.add(marker_7);
|
||||||
|
markersList.add(marker_8);
|
||||||
|
markersList.add(marker_9);
|
||||||
|
markersList.add(marker_10);
|
||||||
|
markersList.add(marker_11);
|
||||||
|
markersList.add(marker_12);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
late GoogleMapController googleMapController;
|
late GoogleMapController googleMapController;
|
||||||
|
|
||||||
|
@ -60,7 +256,7 @@ class MapState extends State<Map> {
|
||||||
GoogleMap(
|
GoogleMap(
|
||||||
mapType: MapType.normal,
|
mapType: MapType.normal,
|
||||||
initialCameraPosition: _kGooglePlex,
|
initialCameraPosition: _kGooglePlex,
|
||||||
markers: markersList,
|
markers: markersList.map((e) => e).toSet(),
|
||||||
onMapCreated: (GoogleMapController controller) {
|
onMapCreated: (GoogleMapController controller) {
|
||||||
_controller.complete(controller);
|
_controller.complete(controller);
|
||||||
},
|
},
|
||||||
|
@ -112,3 +308,12 @@ class MapState extends State<Map> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _Marker {
|
||||||
|
|
||||||
|
var Plats_1;
|
||||||
|
var Gatunr_1;
|
||||||
|
var coordinates;
|
||||||
|
|
||||||
|
_Marker(this.Plats_1, this.Gatunr_1, this.coordinates);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user