-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest2.html
115 lines (104 loc) · 3.39 KB
/
test2.html
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var geocoder;
var map;
function codeAddress(address) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var circle ={
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: .4,
scale: 4.5,
strokeColor: 'white',
strokeWeight: 1
};
var marker = new google.maps.Marker({
map: map,
icon: circle,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
function plot_all(data) {
for( var i in data ) {
var entry = data[i];
var latlng = new google.maps.LatLng(entry.geocode.lat, entry.geocode.lng);
circle ={
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: .4,
scale: 4.5,
strokeColor: 'white',
strokeWeight: 1
};
var marker = new google.maps.Marker({
map: map,
icon: circle,
position: latlng
});
}
}
function retrieve_and_plot( json_url ) {
$.ajax({
url: json_url,
data: '',
type: 'GET',
dataType: 'json',
success: function(data)
{
$('#incidents').html('');
plot_all( data );
// for (var i in data) {
// $('#incidents').append('Address: ' + data[i]["Location of Occurrence"] + '</br>');
// codeAddress( data[i]["Location of Occurrence"] + ", pittsburgh, pa" )
// }
}
});
return false; // keeps the page from not refreshing
};
$(document).ready(function(){
$( "#file-list" ).load( "/ ul",
function() {
$( "a" ).click( function(){
retrieve_and_plot(this.href);
return false;
}
)
}
);
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(40.440415,-80.000063);
var mapOptions = {
zoom: 13,
center: latlng
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
});
</script>
</head>
<body>
<div id="file-list" style="float: left; padding-right: 10px;"></div>
<div id="map-canvas"></div>
<div id="incidents"></div>
</body>
</html>