-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap.html
132 lines (116 loc) · 3.62 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BullTwitter</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
/* start styles for the ContextMenu */
.context_menu{
background-color:white;
border:1px solid gray;
}
.context_menu_item{
padding:3px 6px;
}
.context_menu_item:hover{
background-color:#CCCCCC;
}
.context_menu_separator{
background-color:gray;
height:1px;
margin:0;
padding:0;
}
#clearDirectionsItem, #getDirectionsItem{
display:none;
}
/* end styles for the ContextMenu */
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=visualization"></script>
<script type="text/javascript", src="ContextMenu.js"></script>
<script>
var map;
var position ;
function initialize() {
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(39.9522222,-75.1641667),
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.BOTTOM_CENTER
}
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
ws = new WebSocket("ws://localhost:8567/");
// new context menu to enable right-click option to make tweet from that point
var contextMenuOptions={};
contextMenuOptions.classNames={menu:'context_menu', menuSeparator:'context_menu_separator'};
// create an array of ContextMenuItem objects
// an 'id' is defined for each of the four directions related items
var menuItems=[];
menuItems.push({className:'context_menu_item', eventName:'bulltweet', id:'directionsOriginItem', label:'Tweet from here'});
menuItems.push({className:'context_menu_item', eventName:'bulltweet_image', id:'directionsOriginItem', label:'Tweet+Image from here'});
contextMenuOptions.menuItems=menuItems;
var contextMenu=new ContextMenu(map, contextMenuOptions);
google.maps.event.addListener(map, 'rightclick', function(mouseEvent){
contextMenu.show(mouseEvent.latLng);
position = mouseEvent.latLng;
});
google.maps.event.addListener(contextMenu, 'menu_item_selected', function(latLng, eventName){
switch(eventName){
case 'bulltweet':
bullTweet();
break;
case 'bulltweet_image':
document.getElementById('upload').click();
document.getElementById('upload').onchange = tweetImage;
break;
}
});
}
function tweetImage() {
imgfile = this.value;
var lastIndex = imgfile.lastIndexOf("\\");
if (lastIndex >= 0) {
imgfile = imgfile.substring(lastIndex + 1);
}
var msg = prompt("Enter your tweet status.");
ws.send("IMG" + imgfile + position + msg);
}
function bullTweet() {
var msg = prompt("Enter your tweet status.");
msgbody = position + msg;
ws.send(msgbody);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
<div id="panel">
<button onclick="initialize()">Reset Map</button>
<input id="pac-input" class="controls" type="text" placeholder="Search Location">
<input type="file" id="upload" style="display: none;"/>
</div>
<script type="text/javascript", src="ContextMenu.js"></script>
</body>
</div>
</html>