This repository was archived by the owner on Feb 13, 2025. It is now read-only.
forked from larabhd/Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
202 lines (99 loc) · 4.13 KB
/
index.html
File metadata and controls
202 lines (99 loc) · 4.13 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Location!</title>
<style>
#map{
height: 400px;
width: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCWr5rQ2T38wSrxhG8zk_mOqvCYmDXymrk&callback=initMap"
async defer>
</script>
<script src="js/bootstrap.min.js" /> </script>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<script type="text/javascript">
var myLat;
var myLng;
//retreiving URL from Google GeoCode API.....
// auto complete map search login.................
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-63072743-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-63072743-1');
</script>
<meta property=”og:title” content=”GEOCODE” />
<meta property=”og:url” content=”http://www.ourlocationtrackingdomain.comingsoon” />
<meta property=”og:description” content=”Get longitude and latitude of any location in the world by just entering the adress of that location” />
</head>
<body>
<div class="container">
<div id="map"></div>
<p id="demo"></p>
<br><br>
<strong> Address: </strong> <input type="text" size="40" id="address" >
<br><br>
<strong> Latitude: </strong> <input type="text" id="lati" >
<strong> Longitude: </strong> <input type="text" id="lngi" ><br>
</div>
<script>
// GOOGLE MAP.......................................
function initMap(){
//map options variable...
var options = {
zoom:10,
center:{lat:40.7830603 , lng:-73.9712488}
}
//showing google maps in div...
var map = new google.maps.Map(document.getElementById('map'), options);
//adding marker...
//var marker = new google.maps.Marker({position: {lat:myLat , lng:myLng},map:map,
//icon:'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'});
}
//END GOOGLE MAP...............................................................
function load() {
//var locationAddress = document.getElementById("myText").value;
var url_string = window.location.href;
var url = new URL(url_string);
var userLocation = url.searchParams.get("mapLocation");
console.log(userLocation);
var googleApiEndpoint = "https://maps.googleapis.com/maps/api/geocode/json?address="+userLocation+"&key=AIzaSyCWr5rQ2T38wSrxhG8zk_mOqvCYmDXymrk";
loadJSON(googleApiEndpoint, function(response) {
var actual_JSON = JSON.parse(response);
console.log(actual_JSON);
console.log(actual_JSON['results'][0]['geometry']['location']['lat']);
console.log(actual_JSON['results'][0]['geometry']['location']['lng']);
myLat = actual_JSON['results'][0]['geometry']['location']['lat'];
myLng = actual_JSON['results'][0]['geometry']['location']['lng'];
document.getElementById("lati").value = myLat;
document.getElementById("lngi").value = myLng;
document.getElementById("address").value = userLocation;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(myLat,myLng),
map: map
});
});
}
//intililizing the script.....
load();
function loadJSON(file, callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', file, true); // Replace 'my_data' with the path to your file
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
// Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
callback(xobj.responseText);
}
};
xobj.send(null);
}
</script>
<hr>
</body>
</html>