-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctionmap.js
69 lines (56 loc) · 2.49 KB
/
functionmap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var indexapp = angular.module('indexapp', []);
indexapp.controller('indexcontroller', function($scope,$rootScope,$http) {
$scope.cordinates=[];
$scope.hospitaldata=[];
$scope.Latitude="";
$scope.Longitude="";
window.onload = function () {
$scope.note=false;
var mapOptions = {
center: new google.maps.LatLng(28.6139, 77.2090),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var latlngbounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
google.maps.event.addListener(map, 'click', function (e) {
alert("Latitude: " + e.latLng.lat() + "\r\nLongitude: " + e.latLng.lng());
var coordinates={
Latitude:e.latLng.lat(),
Longitude:e.latLng.lng(),
shelternote:prompt("Hi,What are some of shelters available nearby?"),
atmnote:prompt("Are,there any ATM nearby?")
}
var lat = e.latLng.lat();
var lng = e.latLng.lng();
var shelter=coordinates.shelternote;
var atmnote=coordinates.atmnote;
window.location.href = "myphpfile.php?lat=" + lat + "&lng="+lng+ "&shelter="+shelter+ "&atmnote="+atmnote;
$rootScope.$broadcast('note',coordinates);
$scope.cordinates.push(coordinates);
console.log($scope.cordinates);
var myCenter=new google.maps.LatLng(e.latLng.lat(),e.latLng.lng());
var marker=new google.maps.Marker({
position:myCenter,
});
marker.setMap(map)
var note=true;
});
$http.get("http://localhost/TravelEasy/jsonview1.php")
.success(function (hospitaldata) {
$scope.hospitaldata = hospitaldata;
console.log($scope.hospitaldata)
console.log($scope.hospitaldata.length)
for(var i=0;i<$scope.hospitaldata.length;i++){
$scope.Latitude=$scope.hospitaldata[i].lat;
$scope.Longitude=$scope.hospitaldata[i].lng;
var myCenter=new google.maps.LatLng($scope.Latitude,$scope.Longitude);
var marker=new google.maps.Marker({
position:myCenter,
});
marker.setMap(map)
}
});
}
});