-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (48 loc) · 1.31 KB
/
index.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
49
50
51
52
53
function initMap(lat, log) {
map = new google.maps.Map(document.getElementById("map"), {
// center: { lat: 34.66792141379477, lng: 135.4306804301658 },
center: { lat: lat, lng: log },
zoom: 18,
mapId: "ff1c23d39579fc60",
});
// Name
// Latitude, Longitude
// Image URL
// scaledSize width, height
const markers = [
["Yoshi;s House", lat, log, "./img/star.png", new google.maps.Size(38, 31)],
];
const marker = new google.maps.Marker({
position: { lat: lat, lng: log },
map,
animation: google.maps.Animation.DROP,
title: "Hello World!",
icon: {
url: "./img/star.png",
scaledSize: new google.maps.Size(38, 31),
},
//34.66721548545568, 135.4318284155447
});
const infowindow = new google.maps.InfoWindow({
content: "my position",
});
marker.addListener("click", () => {
infowindow.open(map, marker);
});
}
function nowPosition() {
navigator.geolocation.getCurrentPosition(handleGeoSucces, handleGeoError);
}
function handleGeoSucces(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
const coordsObj = {
latitude,
longitude,
};
initMap(latitude, longitude);
}
function handleGeoError() {
console.log("cant access geo postion");
}
//34.66792141379477, 135.4306804301658