-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_places.php
104 lines (84 loc) · 2.75 KB
/
add_places.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
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
<?php
session_start();
include_once("server.php");
include_once("functions.php");
?>
<html>
<head>
<title>
Add places you have visited
</title>
</head>
<body>
<?php
if($_POST["submit"]){
$address = $_POST['address'];
$place_x = $_POST["placex"];
$place_y = $_POST["placey"];
$sql = "INSERT INTO markers (address, lat, lng)
VALUES ('" .$_POST['address']. "', '" .$_POST['placex']. "', '" .$_POST['placey']. "');";
$result = mysql_query($sql);
header("Refresh: 5; URL='profile.php'");
}
?>
<form action ="" method="post">
<div id="locationField">
<input id="autocomplete" placeholder="Enter your address"
onFocus="geolocate()" type="text" name="address"></input>
</div>
<input type = "text" name = "placex" id="place_x">
<input type = "text" name = "placey" id="place_y">
<input type = "submit" name = "submit" value = "submit">
</form>
<script>
var placeSearch, autocomplete;
var componentForm = {
street_number: 'short_name',
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name',
postal_code: 'short_name'
};
function initAutocomplete() {
// Create the autocomplete object, restricting the search to geographical
// location types.
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
{types: ['geocode']});
// When the user selects an address from the dropdown, populate the address
// fields in the form.
autocomplete.addListener('place_changed', fillInAddress);
}
// [START region_fillform]
function fillInAddress() {
// Get the place details from the autocomplete object.
var place = autocomplete.getPlace();
document.getElementById('place_x').value = place.geometry.location.lat();
document.getElementById('place_y').value = place.geometry.location.lng();
}
// [END region_fillform]
// [START region_geolocation]
// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
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());
});
}
}
// [END region_geolocation]
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA84DmOq0GA7J3Pp1ikXA7gPZg7FHzqxo0&signed_in=true&libraries=places&callback=initAutocomplete"
async defer></script>
</body>
</html>