map.html
3.28 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
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name = " description" content ="Open Map and find karaoke">
<meta name = "author" content = "Hyun Soo Yoo">
<title>Coin_Karaoke_Map</title>
<style>
div{
height: 100vh;
background-image: url('C:/Users/user/Documents/coinkaraoke/css/Sing.jpg');
background-repeat : no-repeat;
background-size : cover;
}
</style>
<!-- <link rel="stylesheet" href="css/map.css"> -->
<!-- link x -->
</head>
<body>
<H2 id = "title_message">
<center>코인 노래방 검색창</center>
</H2>
<div id="map" style="width:95%;height:600px;"></div>
<script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=8bdb655edc6934f343aaf0c8655559ca">
</script>
<script>
var mapContainer = document.getElementById('map'); // div to display map
var mapOption = {
center: new kakao.maps.LatLng(33.450701, 126.570667), // coordinates of the center of the map
level: 3 // Magnification level of the map
};
// Create a map with a div to display the map and map options
var map = new kakao.maps.Map(mapContainer, mapOption);
if (navigator.geolocation) {
// Get the connection location using GeoLocation
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude, // latitude
lon = position.coords.longitude; // longitude
// Creates the location where the marker will be displayed with the coordinates obtained from geolocation
var locPosition = new kakao.maps.LatLng(lat, lon)
message = '<div style="padding:1px;">여기에 계신가요?!</div>';
// display a marker
displayMarker(locPosition,message);
});
}
else { // When HTML5 GeoLocation is not available, set the marker display location and infowindow content
var locPosition = new kakao.maps.LatLng(33.450701, 126.570667),
message = 'geolocation을 사용할수 없어요..'
displayMarker(locPosition,message);
}
//function to display a marker on the map
function displayMarker(locPosition, message) {
// create a marker
var marker = new kakao.maps.Marker({
map: map,
position: locPosition
});
var iwContent = message, //Contents to display in info window
iwRemoveable = true;
// make info window
var infowindow = new kakao.maps.InfoWindow({
content : iwContent,
removable :iwRemoveable
});
// Display the info window on the marker
infowindow.open(map, marker);
// Change the map center coordinates to the connection location
map.setCenter(locPosition);
}
</script>
</body>
</html>