-
Notifications
You must be signed in to change notification settings - Fork 0
/
googleMaps.js
84 lines (68 loc) · 2.12 KB
/
googleMaps.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function initialize() {
var mapOptions = {
}
var image = 'pharmacy1.png';
var infowindow = new google.maps.InfoWindow();
var bounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var i = 0;
<?php
$pharmacy = $_SESSION['pharmacy'];
$parish = $_SESSION['parish'];
$municipality = $_SESSION['municipality'];
$pharmaciesXML = searchPharmaciesXML($parish);
$pharmaciesParish = exportPharmaciesFromXML($pharmaciesXML);
foreach($pharmaciesParish as $p) {
if($p->getId() == $pharmacy){
$name = $p->getName();
$lat = $p->getLat();
$long = $p->getLong();
}
}?>
var myLatLng = new google.maps.LatLng(<?php echo $lat ?>, <?php echo $long ?>);
var marker = new MarkerWithLabel({
position: myLatLng,
map: map,
title: "<?php echo $name; ?>",
labelContent: "<?php echo $name; ?>",
labelAnchor: new google.maps.Point(50, 0),
labelClass: "labels",
raiseOnDrag: true,
icon: image
});
bounds.extend(marker.position);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent("<?php echo $name; ?>");
infowindow.open(map, marker);
}
})(marker, i));
i++;
var image = 'pharmacy.png';
<?php
$pharmacies = searchPharmaciesAtServiceRadius($pharmacy, $parish, $municipality);
foreach($pharmacies as $pharmacy){?>
var myLatLng = new google.maps.LatLng(<?php echo $pharmacy->getLat(); ?>, <?php echo $pharmacy->getLong(); ?>);
var marker = new MarkerWithLabel({
position: myLatLng,
map: map,
title: "<?php echo $pharmacy->getName(); ?>",
labelContent: i+". " + "<?php echo $pharmacy->getName(); ?>",
labelAnchor: new google.maps.Point(50, 0),
labelClass: "labels1",
raiseOnDrag: true,
icon: image
});
bounds.extend(marker.position);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent("<?php echo $pharmacy->getName(); ?>");
infowindow.open(map, marker);
}
})(marker, i));
i++;
<?php
}?>
map.fitBounds(bounds);
}
google.maps.event.addDomListener(window, 'load', initialize);