-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.html
78 lines (67 loc) · 2.18 KB
/
test1.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
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
//전역 변수
var map;
var myLatlng;
var marker = null;
var inforwindow = null;
function initMap() {
var myOptions = {
center: new google.maps.LatLng(36.36907, 127.37892),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: true, // 위치 이동 가능여부 설정
zoomControl: true, // 줌 설정 가능여부 설정
streetViewControl: false // 스트리트뷰 사용 가능여부 설정
};
map = new google.maps.Map(document.getElementById("map"),
myOptions);
// 맵을 클릭할 때 호출되는 리스너, 마커의 위치를 클릭 위치로 옮김
map.addListener('click', function(e) {
placeMarkerAndPanTo(e.latLng, map);
});
}
function placeMarkerAndPanTo(latLng, map) {
myLatlng = latLng;
var contentString = '<b>latitude: </b>'+latLng.lat()+'<br> <b>longitude: </b>'+latLng.lng();
if(marker == null){
//마커 생성
marker = new google.maps.Marker({
position: latLng,
map: map
});
//인포윈도우 생성
infowindow = new google.maps.InfoWindow({
content: contentString
});
}
marker.setPosition(latLng);
map.panTo(latLng);
infowindow.setContent(contentString);
infowindow.open(map,marker);
// QT단에서 주입한 오브젝트를 통해 시그널 호출
locInfo.sltLocationChanged(latLng.lat(),latLng.lng(),1);
}
</script>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCaOF6CBwv11EhPcAvFwCoyrXBokMytg34&callback=initMap"
async defer></script>
</body>
</html>