-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup.js
48 lines (43 loc) · 1.07 KB
/
backup.js
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
<script>
function initMap(){
// Map options
var options = {
zoom:8,
center:{lat:28.6139,lng:77.2090}
}
// New map
var map = new google.maps.Map(document.getElementById('map'), options);
var marker = new google.maps.Marker({
position: {
lat: 28.6139,
lng: 77.2090
},
map: map,
draggable: true
});
google.maps.event.addListener(marker, 'dragend', function() {
console.log(marker.getPosition().lat());
console.log(marker.getPosition().lng());
});
}
</script>
function geocodeLatLng(obj) {
var latlng = {lat: obj.lat, lng: obj.lng};
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
if (results[0]) {
map.setZoom(11);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
infowindow.setContent(results[0].formatted_address);
infowindow.open(map, marker);
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
}