-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdynamic.html
156 lines (108 loc) · 5.94 KB
/
dynamic.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="../static/dynamic.css">
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<div class="parent">
<div class="absolute">
<div class="card border-secondary mb-3" style="max-width: 18rem;" style="align-items: center;">
<div class="card-header"><b>Add People</b></div>
<div class="container" style="align-items: center;">
<div class="row">
<div class="control-group" id="fields">
<label class="control-label" for="field1">Enter Locations</label>
<div class="controls">
<form role="form" method="POST" action="">
<fieldset class="form-group">
<div class="form-group">
{{ form.final_submit(class="btn-outline-info") }}
</div>
<div class="entry input-group col-xs-3 form-group" id="listof">
{{ form.address1(class="form-control form-control-lg", id="autocomplete" , placeholder="Enter location") }}
<div class="form-group">
{{ form.new_user(class="btn-add") }}
</div>
</div>
<input type="hidden" name="hide_f" id="hide_i" value="0" >
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id='map'></div>
<script>
document.getElementsByClassName("close").value="x";
document.getElementsByClassName("btn_add").value="+";
var map;
function initialize(){
initMap();
initAutocomplete();
}
function initMap() {
console.log("initmap called");
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: {lat: -34.397, lng: 150.644}
});
var geocoder = new google.maps.Geocoder();
document.getElementById('new_user').addEventListener('click', function() {
geocodeAddress(geocoder, map);
});
}
var counter=1;
function geocodeAddress(geocoder, resultsMap) {
console.log("geo called");
console.log('abc-'+String(counter));
var address = document.getElementById('abc-'+String(counter)).value;
counter++;
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK' ) {
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
var placeSearch, autocomplete;
var input_loc;
function initAutocomplete() {
// Create the autocomplete object, restricting the search predictions to
// geographical location types.
//do something with each element
autocomplete = new google.maps.places.Autocomplete(document.getElementById("autocomplete"),{types: ['geocode']});
// Avoid paying for data that you don't need by restricting the set of
// place fields that are returned to just the address components.
autocomplete.setFields(['address_component']);
}
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle(
{center: geolocation, radius: position.coords.accuracy});
autocomplete.setBounds(circle.getBounds());
});
}
}
</script>
<script type="text/javascript" src="../static/add_remove.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCd3yT-00TDYD1gYM6WWWKTO6kxOVr-ho8&libraries=places&callback=initialize"
async defer></script>
</body>
</html>