forked from thesunRider/Reubus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap_test.html
100 lines (85 loc) · 2.64 KB
/
map_test.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
<!DOCTYPE html>
<html>
<head>
<title>Getting LatLng from a Click Event</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<input type="hidden" id="latlong" value="">
<input type="hidden" id="debug" value="">
<script>
var map ;
var infoWindow;
function initMap() {
var myLatlng = {lat: -25.363, lng: 131.044};
map = new google.maps.Map(
document.getElementById('map'), {zoom: 15, center: myLatlng});
// Create the initial InfoWindow.
google.maps.event.addListenerOnce(map, 'idle', function () {
document.getElementById("debug").value = 1256;
});
infoWindow = new google.maps.InfoWindow(
{content: 'Click the map to get Lat/Lng info!', position: myLatlng});
infoWindow.open(map);
// Configure the click listener.
map.addListener('click', function(mapsMouseEvent) {
// Close the current InfoWindow.
infoWindow.close();
// Create a new InfoWindow.
infoWindow = new google.maps.InfoWindow({position: mapsMouseEvent.latLng});
infoWindow.setContent(mapsMouseEvent.latLng.toString());
document.getElementById("latlong").value = mapsMouseEvent.latLng.toString();
infoWindow.open(map);
});
}
function zoomtolocation(lats,longs) {
map.setCenter(new google.maps.LatLng(lats,longs));
}
function infowindowshow(lats,longs,contentman){
infoWindow.close();
var infowindowm = new google.maps.InfoWindow({
content: contentman
});
infowindowm.setPosition({lat: lats, lng: longs});
infowindowm.open(map);
}
function drawcircle(tit,lat,lng,rad,colr,opac){
// Create marker
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(lat, lng),
title: tit
});
// Add circle overlay and bind to marker
var circle = new google.maps.Circle({
map: map,
strokeColor: "#FFFFFF",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: colr,
fillOpacity: opac,
radius: rad
});
circle.bindTo('center', marker, 'position');
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=<key>&callback=initMap">
</script>
</body>
</html>