Skip to content

Commit

Permalink
Add hospitals
Browse files Browse the repository at this point in the history
  • Loading branch information
dewmal committed Mar 27, 2020
1 parent b509316 commit e836e3d
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 1 deletion.
214 changes: 214 additions & 0 deletions assets/hospitals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
{
"hospitals": [
{
"name": "NHSL",
"lon": 6.917705000000001,
"lat": 79.866385,
"id": 1,
"hsId": "LCB0000018"
},
{
"name": "NH Kandy",
"lon": 7.287566,
"lat": 80.631834,
"id": 2,
"hsId": "LKY0001008"
},
{
"name": "LRH",
"lon": 6.918231,
"lat": 79.876479,
"id": 3,
"hsId": "LCB0000216"
},
{
"name": "CSHW",
"lon": 6.910289,
"lat": 79.884778,
"id": 4,
"hsId": "LCB0000166"
},
{
"name": "IDH",
"lon": 6.922314999999999,
"lat": 79.916981,
"id": 5,
"hsId": "LCB0000117"
},
{
"name": "CNTH Ragama",
"lon": 7.028176147000001,
"lat": 79.92352948,
"id": 6,
"hsId": "LGP0000703"
},
{
"name": "TH Anuradhapura",
"lon": 8.324937955,
"lat": 80.41297135,
"id": 7,
"hsId": "LAN0000034"
},
{
"name": "T H Batticaloa",
"lon": 7.708293551000001,
"lat": 81.69119854,
"id": 8,
"hsId": "LBC0000075"
},
{
"name": "TH Rathnapura",
"lon": 6.6866923,
"lat": 80.3925328,
"id": 9,
"hsId": ""
},
{
"name": "TH Karapitiya",
"lon": 6.066744,
"lat": 80.226084,
"id": 10,
"hsId": "LGL0000620"
},
{
"name": "TH Kurunegala",
"lon": 7.4794793539999995,
"lat": 80.35857174,
"id": 11,
"hsId": ""
},
{
"name": "TH Jaffna",
"lon": 9.665931,
"lat": 80.014377,
"id": 12,
"hsId": "LJF0000786"
},
{
"name": "PGH Badulla",
"lon": 6.990918,
"lat": 81.05161899999999,
"id": 13,
"hsId": ""
},
{
"name": "BH Mulleriyawa",
"lon": 6.92605,
"lat": 79.943753,
"id": 14,
"hsId": "LCB0000125"
},
{
"name": "DGH Hambantota",
"lon": 6.126806998999999,
"lat": 81.12261318,
"id": 15,
"hsId": ""
},
{
"name": "DGH Negombo",
"lon": 7.21235,
"lat": 79.84828167,
"id": 16,
"hsId": ""
},
{
"name": "DGH Gampaha",
"lon": 7.091504700000001,
"lat": 79.9999527,
"id": 17,
"hsId": ""
},
{
"name": "BH Chilaw",
"lon": 7.57220396,
"lat": 79.79742705,
"id": 18,
"hsId": ""
},
{
"name": "DGH Polonnaruwa",
"lon": 7.9425338000000005,
"lat": 81.0092566,
"id": 19,
"hsId": ""
},
{
"name": "DGH Vavuniya",
"lon": 8.760660000000001,
"lat": 80.49991,
"id": 20,
"hsId": ""
},
{
"name": "CSTH Kalubowila",
"lon": 6.866891000000001,
"lat": 79.876861,
"id": 21,
"hsId": "LCB0000174"
},
{
"name": "BH Marawila",
"lon": 7.393453,
"lat": 79.8321376,
"id": 22,
"hsId": ""
},
{
"name": "DGH Monaragala",
"lon": 6.8918800000000005,
"lat": 81.34253000000001,
"id": 23,
"hsId": ""
},
{
"name": "DGH Kalutara",
"lon": 6.563859,
"lat": 79.984344,
"id": 24,
"hsId": ""
},
{
"name": "DGH Matara",
"lon": 5.964130394,
"lat": 80.49414381,
"id": 25,
"hsId": ""
},
{
"name": "KDU",
"lon": 6.8260902,
"lat": 79.9043642,
"id": 26,
"hsId": ""
},
{
"name": "BH Minuwangoda",
"lon": 7.17237,
"lat": 79.95714833,
"id": 27,
"hsId": "PGP0005686"
},
{
"name": "BH Homagama",
"lon": 6.847334768,
"lat": 79.99156892,
"id": 28,
"hsId": "PCB0004002"
},
{
"name": "BH Welikanda",
"lon": 7.947781667,
"lat": 81.245785,
"id": 29,
"hsId": ""
},
{
"name": "Nevile Fernando",
"lon": 6.9244512,
"lat": 79.96039990000001,
"id": 30,
"hsId": ""
}
]
}
Binary file added assets/images/hospital_sign_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions lib/page/screen/case_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CaseDetailScreenState extends State<CaseDetailScreen> {

Position currentLocation;
List<Location> entries = List();
List<Marker> hospitalLocations = List();
Timer _locationTimer;

Timer _currentLoctimer;
Expand Down Expand Up @@ -49,6 +50,23 @@ class CaseDetailScreenState extends State<CaseDetailScreen> {
super.initState();
updateLocation();

parseJsonFromAssets("assets/hospitals.json").then((data) {
BitmapDescriptor.fromAssetImage(
ImageConfiguration(devicePixelRatio: 0.5, size: Size(5, 5)),
"assets/images/hospital_sign_map.png")
.then((icon) {
for (var h in data["hospitals"]) {
setState(() {
hospitalLocations.add(Marker(
icon: icon,
markerId: MarkerId("${h["id"]}_id"),
infoWindow: InfoWindow(title: "${h["name"]}"),
position: LatLng(h["lon"], h["lat"])));
});
}
});
});

WidgetsBinding.instance.addPostFrameCallback((_) {
_channel.invokeMethod('requestLocationPermission').then((res) {
_channel.invokeMethod('openLocationService').then((res) {});
Expand Down Expand Up @@ -86,6 +104,13 @@ class CaseDetailScreenState extends State<CaseDetailScreen> {
});
}

Future<Map<String, dynamic>> parseJsonFromAssets(String assetsPath) async {
print('--- Parse json from: $assetsPath');
return rootBundle
.loadString(assetsPath)
.then((jsonStr) => jsonDecode(jsonStr));
}

void moveMapToCurrentLoc() async {
final GoogleMapController controller = await _controller.future;
final CameraPosition _camPos = CameraPosition(
Expand All @@ -112,6 +137,7 @@ class CaseDetailScreenState extends State<CaseDetailScreen> {
Widget getMapView(List<Location> entries) {
return GoogleMap(
mapType: MapType.normal,
markers: hospitalLocations.toSet(),
circles: entries.map((l) {
return Circle(
circleId: CircleId("${l.date.millisecondsSinceEpoch}"),
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Self tracking app
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.4.0+16
version: 1.4.0+17

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down Expand Up @@ -70,7 +70,9 @@ flutter:
- assets/lang/en.json
- assets/lang/si.json
- assets/lang/ta.json
- assets/hospitals.json
- assets/images/logo.png
- assets/images/hospital_sign_map.png
- assets/images/suspected_icon.png
- assets/images/user_icon.png
- assets/data/constant_data.json
Expand Down

0 comments on commit e836e3d

Please sign in to comment.