-
Notifications
You must be signed in to change notification settings - Fork 6
/
view-of-uk-independent-living-support-services.php
117 lines (98 loc) · 3.92 KB
/
view-of-uk-independent-living-support-services.php
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
<html dir="ltr" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>General Map Thing</title>
<style type="text/css" media="screen">p{padding:1px;}</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<h2>General Map Thing of <span id="scrapername">...</span> <em id="message">...</em></h2>
<div id="map" style="width:100%;height:700px"></div>
<script type="text/javascript" charset="utf-8">
// ####################################################################
// Start of javascript code. You should edit the functions below
// so that your map expresses the particular contents of the data
// ####################################################################
var sourcescraper = 'directory-of-local-support-services-uk';
$('#scrapername').html('<b>'+sourcescraper+'</b>');
// ####################################################################
// Set the dynamic icon for your point. For more see:
// http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html
// ####################################################################
function mapicon(record)
{
col = 'F00';
if (record["Decision"] == "PENDING")
col = '0F0';
letter = 'O';
if (record["Decision"] == "PENDING")
letter = 'P';
icon = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+letter+'|'+col+'|000';
return icon
}
// ####################################################################
// Set the tooltip title value
// ####################################################################
function mapicontext(record)
{
return "TOOLTIP " + record["Reference_number"]
}
// ####################################################################
// Set the popup text for your pin, usually with the link
// ####################################################################
function mapicontent(record)
{
return '<a href="'+record['web']+'" target="_blank">'+record["name"]+'</a><br>'+record["address"];
}
var map;
var centreset = false;
function makemap()
{
var mapOptions = { "zoom": 6, "center": new google.maps.LatLng(55.500515, -4.128317),
"mapTypeId": google.maps.MapTypeId.SATELLITE };
map = new google.maps.Map(document.getElementById("map"), mapOptions);
}
function recorddata(record)
{
if (!record['latlng_lat'])
return;
pos = new google.maps.LatLng(record['latlng_lat'], record['latlng_lng']);
//text = mapicontext(record);
// icon = mapicon(record);
content = mapicontent(record);
marker = new google.maps.Marker({position:pos,map:map});
infowindow = new google.maps.InfoWindow({ content: content });
(function(j) {
google.maps.event.addListener(j.marker, "click", function(){
j.infowindow.open(map, j.marker); });
})({'marker':marker, 'infowindow':infowindow});
if (!centreset)
{ map.setCenter(pos); centreset = true }
}
var olength = 500;
var olimit = 100;
var offset = 0; 1
function gotback(r)
{
for (i = 0; i < r.length; i++)
recorddata(r[i]);
offset += olength;
if ((r.length == olength) && (offset < olimit))
loaddata();
else
$("#message").html("Total records=" + (offset - olength + r.length));
}
function loaddata()
{
$("#message").html("Loading ...");
var s = document.createElement('script');
url = "http://api.scraperwiki.com/api/1.0/datastore/getdata?&format=json&name="+sourcescraper+"&limit="+olength+"&callback=gotback&offset=" + offset;
s.setAttribute('src', url);
s.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
}
$(function() { makemap(); loaddata(); });
</script>
</body>
</html>