Skip to content

Instantly share code, notes, and snippets.

@ricroberts
ricroberts / map-manager.js
Created September 19, 2011 16:10
IMD Map Explorer initial map-manager
(function() {
// the constructor.
var MapManager = function(googleMap, initialScoreDomain) {
self = this;
map = googleMap;
scoreDomain = initialScoreDomain;
};
// public API
@ricroberts
ricroberts / head.html
Created September 28, 2011 11:18
head (in progress)
<head>
<!-- other stuff here ... -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="javascripts/raphael.js"></script>
<script src="javascripts/swirrl.js"></script>
<script src="javascripts/swirrl/map-manager.js"></script>
</head>
@ricroberts
ricroberts / map-manager.js
Created September 28, 2011 12:26
Map Manager refresh function
// public api.
MapManager.prototype = {
refresh: function() {
$(this).trigger('started');
var tiles = getTiles();
getBoundaryData(tiles);
}
}
@ricroberts
ricroberts / map-manager.js
Created September 28, 2011 12:42
getBoundaryData
// private functions
// ...
var getBoundaryData = function(tiles) {
var noOfTiles = tiles.length;
// nothing to do.
if(noOfTiles == 0) {
@ricroberts
ricroberts / map-manager.js
Created September 28, 2011 12:46
private variable for boundaryData
// private variables
var map
, scoreDomain
, boundaryData = {} // map of tiles -> data
, self;
@ricroberts
ricroberts / map-manager.js
Created September 28, 2011 13:15
Handle the boundaryDataRetrieved and DataError events in the constructor
$(this).bind('boundaryDataRetrieved', function() {
refreshPolygons();
});
$(this).bind('dataError', function() {
$(this).trigger('finished'); // tell people we're done
});
@ricroberts
ricroberts / query.sparql
Created September 28, 2011 20:04
SPARQL query for LSOA data
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?lsoa ?notation ?label ?lat ?long ?score
WHERE {
GRAPH <http://opendatacommunities.org/id/graph/geography/lsoa> {
?lsoa a <http://opendatacommunities.org/def/geography#LSOA> .
?lsoa geo:lat ?lat .
?lsoa geo:long ?long .
?lsoa <http://www.w3.org/2004/02/skos/core#notation> ?notation .
@ricroberts
ricroberts / map-manager.js
Created January 19, 2012 12:09
Map Manager structure
(function() {
// the constructor.
var MapManager = function(googleMap, initialScoreDomain) {
}
// public API
MapManager.prototype = {
}
@ricroberts
ricroberts / map-manager.js
Created January 19, 2012 12:22
MapManager Constructor
var MapManager = function(googleMap, initialScoreDomain) {
self = this;
map = googleMap;
scoreDomain = initialScoreDomain;
$(this).bind('lsoaDataRetrieved', function() {
lsoaDataRetrieved = true;
// TODO: this is where we'll refresh the polygons on the map, later.
// for now, just log out the lsoa data, and say we've done
@ricroberts
ricroberts / map-manager.js
Created January 19, 2012 12:31
MapManager refresh
MapManager.prototype = {
refresh: function() {
$(this).trigger('started');
errored = false;
// clear these variables for this refresh
if (map.getZoom() > minZoom) {
$(this).trigger('zoomOK');
var tiles = getTiles();