-
Notifications
You must be signed in to change notification settings - Fork 0
/
Version 0.4
280 lines (217 loc) · 6.24 KB
/
Version 0.4
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html,
body {
height: 100%;
background: cornflowerblue;
}
#Container {
width: 40%;
height: 200px;
background: cornflowerblue;
padding-right: 99%;
padding-bottom: 39%;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: red;
color: white;
}
#title_div {
text-align: center;
position: absolute;
width: 97%;
background: Coral;
height: 4%;
font-size: x-large;
border: 1px solid;
padding: 12px;
<!-- box-shadow: 5px 10px; -->
}
#Search_bar_div {
margin-left: 0%;
height: 30%;
position: absolute;
width: 40%;
margin-top: 4%;
}
#map {
margin-left: 40%;
height: 82%;
background: yellow;
position: absolute;
width: 57%;
margin-top: 4%;
border: 10px solid black;
}
#Entries_div {
position: absolute;
width: 40%;
height: 56%;
margin-top: 18%;
overflow: scroll;
}
input[type="text"] {
display: block;
margin : 0 auto;
position: relative;
top: 20%;
width: 95%;
height: 20%;
font-size: 1vw;
}
#SubmitAddress {
margin-top: 15%;
margin-left: 40%;
}
#Entry_List {
color: white;
list-style-type: none;
line-height: 2em;
font-size : 2em;
}
.Button_Style {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 10%;
cursor: pointer;
text
}
</style>
</head>
<body>
<selection id="Container">
<div id="title_div">
<p center> Google Map API </p /center>
</div>
<div id="Search_bar_div">
<input id="SearchAddress" type="text" class="controls" placeholder="Please Enter a address.">
<button class="Button_Style" id="SubmitAddress" type="Button" onclick="CheckSearchInput()"> Add Address</button>
</div>
<div id="map"></div>
<div id="Entries_div">
<ol id="Entry_List">
</ol>
</div>
</selection>
<div class="footer">
<button class="Button_Style" id="Display_GoogleMapBtn" onclick="HideMap_ExtendSearch_Entry_div()" >Hide Google Map</button>
<button class="Button_Style" id="ImportAddressBtn" >Import Address</button>
<button class="Button_Style" id="ExportAddressBtn" >Export Address</button>
</div>
<script>
function initAutocomplete() {
// Display the map
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 38.251767, lng: -85.753965},
zoom: 13,
mapTypeId: 'roadmap'
});
// Obtain user search and data.
var input = document.getElementById('SearchAddress');
var searchBox = new google.maps.places.SearchBox(input);
var markers = [];
searchBox.addListener('places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
// Clear out the old markers.
markers.forEach(function(marker) {
marker.setMap(null);
});
markers = [];
// For each place, get the icon, name and location.
var bounds = new google.maps.LatLngBounds();
places.forEach(function(place) {
if (!place.geometry) {
console.log("Returned place contains no geometry");
return;
}
var icon = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
// Create a marker for each place.
markers.push(new google.maps.Marker({
map: map,
icon: icon,
title: place.name,
position: place.geometry.location
}));
if (place.geometry.viewport) {
// Only geocodes have viewport.
bounds.union(place.geometry.viewport);
} else {
bounds.extend(place.geometry.location);
}
});
map.fitBounds(bounds);
});
} // End of initAutocomplete Function.
function CheckSearchInput() {
var CheckInput = document.getElementById("SearchAddress").value;
if ( CheckInput === "") {
alert(" Please enter an address. ");
} else {
EntryAdd();
}
}
function EntryAdd() {
let input = document.getElementById("SearchAddress");
let text = input.value;
let newLi = document.createElement("li");
newLi.textContent = text + " ";
let deleteLink = document.createElement("a");
deleteLink.textContent = "[Delete]";
deleteLink.href = "#";
deleteLink.addEventListener("click", deleteItem);
newLi.appendChild(deleteLink);
document.getElementById("Entry_List").appendChild(newLi);
input.value = "";
function deleteItem() {
confirm("Are you sure you want to delete this address: \n"
);
if (confirm === "true") {
document.getElementById("Entry_List").removeChild(newLi);
}
else {
}
}
}
// Function that hides the Map div and extends the Entry and Search divs to the center.
function HideMap_ExtendSearch_Entry_div() {
var x = document.getElementById("map");
if (x.style.display === "none") {
x.style.display = "block";
document.getElementById("Display_GoogleMapBtn").innerHTML = "Hide Google Map";
document.getElementById("Search_bar_div").style.marginLeft = "0%";
document.getElementById("Entries_div").style.width = "40%";
} else {
x.style.display = "none";
document.getElementById("Display_GoogleMapBtn").innerHTML = "Show Google Map";
document.getElementById("Search_bar_div").style.marginLeft = "30%";
document.getElementById("Entries_div").style.width = "99%";
}
}
</script>
<!-- API Key-->
<script src="https://maps.googleapis.com/maps/api/js?key= --Google API Key-- &libraries=places&callback=initAutocomplete"async defer></script>
</body>
</html>