-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
47 lines (41 loc) · 1.12 KB
/
map.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 2
});
$.get('addresses', function(data) {
var lines = data.split('\n');
lines.forEach(addMarker);
}, 'text');
}
function addMarker(element, index, array){
$.getJSON('http://ipinfo.io/'+element+'/', function(data){
console.log(data);
var pointLatLng = new google.maps.LatLng(parseInt(data.loc.split(',')[0]), parseInt(data.loc.split(',')[1]));
var marker = new google.maps.Marker({
position: pointLatLng,
title: data.hostname
});
marker.setMap(map);
});
}
</script>
</body>
</html>