-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html.erb
55 lines (50 loc) · 1.29 KB
/
map.html.erb
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple Polygon</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// This example creates a simple polygon representing the Bermuda Triangle.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: {lat: 59.295378, lng: 17.991845},
});
// Define the LatLng coordinates for the polygon's path.
<% polygons.each do |polygon| %>
var triangleCoords = [
<% polygon.each do |coord| %>
{lat: <%= coord[0] %>, lng: <%= coord[1] %>},
<% end %>
];
// Construct the polygon.
var bermudaTriangle = new google.maps.Polygon({
paths: triangleCoords,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});
bermudaTriangle.setMap(map);
<% end %>
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=<%= config[:maps_key] %>&signed_in=true&callback=initMap"></script>
</body>
</html>