-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
145 lines (118 loc) · 4.37 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link rel="stylesheet" href="/css/googlemaps.css" />
<link rel="stylesheet" href="/css/searchiscope.css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title>Searchiscope</title>
<script src="/js/elm.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyClCqn3uhV1mDziKDoyNCZQnNhe-uOx5sA&libraries=places&callback=initialize"
async defer></script>
</head>
<body>
<div id="wrap">
<div id="left-column">
</div>
<div id="right-column">
<div id="elm-search">
</div>
</div>
</div>
<input id="pac-input" class="controls" type="text" placeholder="Jump to location or click on map">
<div id="map"></div>
<script type="text/javascript">
// Google Maps specific code.
var twitterhq = { lat: 37.7767396, lng: -122.4163715 };
var initialMapCenter = { lat: twitterhq.lat, lng: (twitterhq.lng + 0.3)};
var marker;
var circle;
function mark(latLng) {
sendCoords(latLng.lat(), latLng.lng());
marker.setPosition(latLng);
circle.setCenter(latLng);
}
function shift(latLng) {
return {lat: latLng.lat(), lng: latLng.lng() + 0.3};
}
function initialize() {
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 10,
center: initialMapCenter,
disableDefaultUI: true
});
// This event listener is called when the map is clicked.
google.maps.event.addListener(map, "click", function(event) {
mark(event.latLng);
});
// Add a marker at the center of the map.
addMarker(twitterhq, map);
// Create the search box and link it to the UI element.
var input = document.getElementById("pac-input");
var searchBox = new google.maps.places.SearchBox(input);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
// Bias the SearchBox results towards current map"s viewport.
map.addListener("bounds_changed", function() {
searchBox.setBounds(map.getBounds());
});
searchBox.addListener("places_changed", function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
// For each place, get the icon, name and location.
var bounds = new google.maps.LatLngBounds();
var newCenter;
places.forEach(function(place) {
if (place.geometry.viewport) {
// Only geocodes have viewport.
bounds.union(place.geometry.viewport);
newCenter = place.geometry.viewport.getCenter();
} else {
bounds.extend(place.geometry.location);
newCenter = place.geometry.location;
}
});
mark(newCenter);
map.panTo(shift(newCenter));
});
}
// Adds a marker to the map.
function addMarker(location, map) {
marker = new google.maps.Marker({
position: location,
label: "♥︎",
map: map
});
circle = new google.maps.Circle({
strokeColor: "#FF0000",
strokeOpacity: 0,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.2,
map: map,
center: location,
radius: 10000, // meters
clickable: false
});
}
</script>
<script type="text/javascript">
// Embed Elm code
var searchDiv = document.getElementById("elm-search");
var search = Elm.TwitterSearch.embed(searchDiv);
function sendCoords(lat, lng) {
search.ports.coords.send([lat, lng]);
}
sendCoords(twitterhq.lat, twitterhq.lng);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-76200790-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>