-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_places_coord.php
65 lines (59 loc) · 1.66 KB
/
get_places_coord.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<script src="javascript/jquery.js" type="text/javascript"></script>
<title>Get places's coords</title>
<script>
var geocoder;
$(function(){
geocoder = new google.maps.Geocoder();
window.setInterval(function(){
$.ajax({
type: "GET",
url: "oulunliikenne_places.php?action=geocode",
cache: false,
dataType: "xml",
success: function(xml)
{
$(xml).find('place').each(function()
{
//console.log($(this));
var company_id = $(this).find("company_id").text();
var address = $(this).find("address").text() + ', Oulu, Finland';
geocoder.geocode( { 'address': address + ',Oulu, Finland'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
lat = results[0].geometry.location.A;
lon = results[0].geometry.location.F;
$.ajax({
type: "GET",
url: "oulunliikenne_places.php?action=coord&lat="+lat+"&lon="+lon+"&company_id="+company_id,
cache: false,
dataType: "xml",
success: function(xml)
{
console.log(address + ":" + lat + "-" + lon);
}
});
}
});
/*$.ajax({
type: "GET",
url: "oulunliikenne_places.php?action=coord&lat=",
cache: false,
dataType: "xml",
success: function(xml)
{
}
});*/
});
}
});
}, 5000);
});
</script>
</head>
</body>
</html>