/
BingMaps1.html
64 lines (53 loc) · 2.14 KB
/
BingMaps1.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Bing Maps</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="rx.js" type="text/javascript"></script>
<script src="rx.jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
<script type="text/javascript">
Array.prototype.toObservable = function () {
return Rx.Observable.FromArray(this);
};
function searchTwitter(text) {
var url = "http://search.twitter.com/search.json";
return $.getJSONAsObservable(url,
{ rpp : 100,
q : text });
}
function addPushPin(map, id, date, latitude, longitude, imageUrl, text, details) {
try {
var pinPoint = new VELatLong(latitude, longitude, 0, VEAltitudeMode.RelativeToGround);
var pin = new VEPushpin(id, pinPoint, imageUrl, text, date + " " + details);
map.AddPushpin(pin);
} catch (err) { }
}
$(document).ready(function () {
var map = new VEMap("veMap");
map.LoadMap();
map.SetZoomLevel(2);
Rx.Observable.Interval(10000).Select(function () { return searchTwitter("4sq.com"); }).Switch()
.SelectMany(function (d) {
return d.data.results.toObservable();
})
.Where(function (data) {
return data.geo != null;
})
.Subscribe(
function (data) {
var lat = data.geo.coordinates[0];
var lon = data.geo.coordinates[1];
addPushPin(map, data.id, data.created_at, lat, lon, data.profile_image_url, data.from_user, data.text);
},
function (error) {
alert(error);
});
});
</script>
</head>
<body>
<div id="veMap" style="position:relative; width: 1000px; height: 600px;"></div>
</body>
</html>