Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hospital_prediction
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kalhara H.A.K IT19108964
hospital_prediction
Commits
7a870cd1
Commit
7a870cd1
authored
Nov 13, 2022
by
Amarasinghe W.K.P.G IT19117874
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit new added map folder
parent
664f0aa5
Pipeline
#6243
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
159 additions
and
0 deletions
+159
-0
map/index.php
map/index.php
+121
-0
map/map_api_wrapper.php
map/map_api_wrapper.php
+38
-0
No files found.
map/index.php
0 → 100644
View file @
7a870cd1
<?php
$locations
=
array
();
$uname
=
"root"
;
$pass
=
""
;
$servername
=
"localhost"
;
$dbname
=
"pha"
;
$db
=
new
mysqli
(
$servername
,
$uname
,
$pass
,
$dbname
);
//$number_of_rows = mysql_num_rows($db);
//echo $number_of_rows;
// SELECT med_hospital.hospital_name, med_hospital.h_lat, med_hospital.h_long
// FROM med_hospital
// INNER JOIN med_medicine ON med_hospital.hospital_name=med_medicine.med_hospital_name AND med_medicine.med_name = 'Vitamin E';
if
(
isset
(
$_POST
[
"submit"
]))
{
echo
"Medicine Name - "
.
$_POST
[
'medicine'
]
.
"<br />"
;
$query
=
$db
->
query
(
"SELECT med_hospital.hospital_name, med_hospital.city, med_hospital.h_lat, med_hospital.h_long FROM med_hospital INNER JOIN med_medicine ON med_hospital.hospital_name=med_medicine.med_hospital_name AND med_medicine.med_name = '"
.
$_POST
[
"medicine"
]
.
"'"
);
while
(
$row
=
$query
->
fetch_assoc
()
){
$name
=
$row
[
'hospital_name'
];
$longitude
=
$row
[
'h_long'
];
$latitude
=
$row
[
'h_lat'
];
$link
=
$row
[
'city'
];
$locations
[]
=
array
(
'name'
=>
$name
,
'lat'
=>
$latitude
,
'lng'
=>
$longitude
,
'lnk'
=>
$link
);
}
}
else
{
$query
=
$db
->
query
(
"SELECT * FROM med_pharmacy"
);
while
(
$row
=
$query
->
fetch_assoc
()
){
$name
=
$row
[
'pharmacy_name'
];
$longitude
=
$row
[
'p_long'
];
$latitude
=
$row
[
'p_lat'
];
$link
=
$row
[
'city'
];
$locations
[]
=
array
(
'name'
=>
$name
,
'lat'
=>
$latitude
,
'lng'
=>
$longitude
,
'lnk'
=>
$link
);
}
}
//echo $locations[0]['name'].": In stock: ".$locations[0]['lat'].", sold: ".$locations[0]['lng'].".<br>";
//echo $locations[1]['name'].": In stock: ".$locations[1]['lat'].", sold: ".$locations[1]['lng'].".<br>";
?>
<script
type=
"text/javascript"
src=
"http://maps.googleapis.com/maps/api/js?key=AIzaSyBkPHRLgrz1Uv_ctapXqGgEyFxTI_7aAtk&callback"
></script>
<script
type=
"text/javascript"
>
function
getLocation
(){
console
.
log
(
"
sjdkhksj
"
)
}
var
map
;
var
Markers
=
{};
var
infowindow
;
var
locations
=
[
<?php
for
(
$i
=
0
;
$i
<
sizeof
(
$locations
);
$i
++
){
$j
=
$i
+
1
;
?>
[
'
AMC Service
'
,
'
<p><a href="
<?php
echo
$locations
[
$i
][
'name'
];
?>
">
<?php
echo
$locations
[
$i
][
'name'
];
?>
</a></p>
'
,
<?php
echo
$locations
[
$i
][
'lat'
];
?>
,
<?php
echo
$locations
[
$i
][
'lng'
];
?>
,
0
]
<?php
if
(
$j
!=
sizeof
(
$locations
))
echo
","
;
}
?>
];
var
origin
=
new
google
.
maps
.
LatLng
(
locations
[
0
][
2
],
locations
[
0
][
3
]);
function
initialize
()
{
var
mapOptions
=
{
zoom
:
12
,
center
:
origin
};
map
=
new
google
.
maps
.
Map
(
document
.
getElementById
(
'
map-canvas
'
),
mapOptions
);
infowindow
=
new
google
.
maps
.
InfoWindow
();
for
(
i
=
0
;
i
<
locations
.
length
;
i
++
)
{
var
position
=
new
google
.
maps
.
LatLng
(
locations
[
i
][
2
],
locations
[
i
][
3
]);
var
marker
=
new
google
.
maps
.
Marker
({
position
:
position
,
map
:
map
,
});
google
.
maps
.
event
.
addListener
(
marker
,
'
click
'
,
(
function
(
marker
,
i
)
{
return
function
()
{
infowindow
.
setContent
(
locations
[
i
][
1
]);
infowindow
.
setOptions
({
maxWidth
:
200
});
infowindow
.
open
(
map
,
marker
);
}
})
(
marker
,
i
));
Markers
[
locations
[
i
][
4
]]
=
marker
;
}
locate
(
0
);
}
function
locate
(
marker_id
)
{
var
myMarker
=
Markers
[
marker_id
];
var
markerPosition
=
myMarker
.
getPosition
();
map
.
setCenter
(
markerPosition
);
google
.
maps
.
event
.
trigger
(
myMarker
,
'
click
'
);
}
google
.
maps
.
event
.
addDomListener
(
window
,
'
load
'
,
initialize
);
</script>
<body
>
<form
action=
"index.php"
method=
"POST"
>
<label
for=
"fname"
>
Search Medicine:
</label>
<input
type=
"text"
id=
"medicine"
name=
"medicine"
><br><br>
<input
type=
"submit"
name=
"submit"
value=
"Submit"
>
</form>
<div
style=
"width: 100%; height: 80%;"
id=
"map-canvas"
></div>
</body>
\ No newline at end of file
map/map_api_wrapper.php
0 → 100644
View file @
7a870cd1
<?php
function
geocode
(
$address
){
// url encode the address
$address
=
urlencode
(
$address
);
// google map geocode api url
$url
=
"http://maps.google.com/maps/api/geocode/json?address=
{
$address
}
"
;
// get the json response from url
$resp_json
=
file_get_contents
(
$url
);
// decode the json response
$resp
=
json_decode
(
$resp_json
,
true
);
// response status will be 'OK', if able to geocode given address
if
(
$resp
[
'status'
]
==
'OK'
){
//define empty array
$data_arr
=
array
();
// get the important data
$data_arr
[
'latitude'
]
=
isset
(
$resp
[
'results'
][
0
][
'geometry'
][
'location'
][
'lat'
])
?
$resp
[
'results'
][
0
][
'geometry'
][
'location'
][
'lat'
]
:
''
;
$data_arr
[
'longitude'
]
=
isset
(
$resp
[
'results'
][
0
][
'geometry'
][
'location'
][
'lng'
])
?
$resp
[
'results'
][
0
][
'geometry'
][
'location'
][
'lng'
]
:
''
;
$data_arr
[
'formatted_address'
]
=
isset
(
$resp
[
'results'
][
0
][
'formatted_address'
])
?
$resp
[
'results'
][
0
][
'formatted_address'
]
:
''
;
// verify if data is exist
if
(
!
empty
(
$data_arr
)
&&
!
empty
(
$data_arr
[
'latitude'
])
&&
!
empty
(
$data_arr
[
'longitude'
])){
return
$data_arr
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
echo
json_encode
(
geocode
(
'denver'
));
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment