Skip to content

Commit

Permalink
Adding label toggler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Palazzolo committed Jun 18, 2012
1 parent 0c3aebe commit 1c8fc9b
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions visualizations/index.html
Expand Up @@ -146,6 +146,23 @@
float: right; float: right;
margin: 13px 16px 0 0; margin: 13px 16px 0 0;
} }

a.label-toggler {
background: #BBBBBB;
background: rgba(255, 255, 255, 0.7);
overflow: hidden;
display: block;
vertical-align: text-top;
opacity: 0.9;
margin: 0 0 0 5px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
margin: 0 0 10px 10px;
padding: 2px 6px;
font-size: .85em;
color: #111111;
}
</style> </style>


<div id="minnpost-invasive-species-application"> <div id="minnpost-invasive-species-application">
Expand Down Expand Up @@ -292,22 +309,47 @@ <h3><%= title %></h3>
{ attribution: attribution, scheme: 'tms' }); { attribution: attribution, scheme: 'tms' });
map.addLayer(minnpost); map.addLayer(minnpost);


// Labels layer with button to turn off and on
var tiles = 'http://{s}.tiles.minnpost.com/minnpost-basemaps/' +
'minnpost-minnesota-night-labels/{z}/{x}/{y}.png';
var minnpostLabels = new L.TileLayer(tiles, { scheme: 'tms' });
$('.leaflet-control-container .leaflet-bottom.leaflet-left')
.append(
$('<a>Show labels</a>').addClass('label-toggler')
.addClass('label-toggler-on')
.click(function(e) {
$thisA = $(this);
if ($thisA.hasClass('label-toggler-on')) {
$thisA.html('Hide labels');
map.addLayer(minnpostLabels);
}
else {
$thisA.html('Show labels');
map.removeLayer(minnpostLabels);
}
$thisA.toggleClass('label-toggler-on');
})
);

// Tilejson layer of species // Tilejson layer of species
var metadata = 'http://a.tiles.minnpost.com/minnpost-dnr-invasive/mn-invasive/tilejson.jsonp'; var metadata = 'http://a.tiles.minnpost.com/minnpost-dnr-invasive/mn-invasive/tilejson.jsonp';
wax.tilejson(metadata, function(tilejson) { wax.tilejson(metadata, function(tilejson) {
// Hack the planet (aka the tilejson) // Hack the planet (aka the tilejson)
tilejson.scheme = 'tms'; tilejson.scheme = 'tms';
// For testing purposes, use S3 directly as opposed to Cloudfront.
/*
tilejson.tiles = [ tilejson.tiles = [
'https://s3.amazonaws.com/a.tiles.minnpost/minnpost-dnr-invasive/mn-invasive/{z}/{x}/{y}.png' 'https://s3.amazonaws.com/a.tiles.minnpost/minnpost-dnr-invasive/mn-invasive/{z}/{x}/{y}.png'
]; ];
tilejson.grids = [ tilejson.grids = [
'https://s3.amazonaws.com/a.tiles.minnpost/minnpost-dnr-invasive/mn-invasive/{z}/{x}/{y}.grid.json' 'https://s3.amazonaws.com/a.tiles.minnpost/minnpost-dnr-invasive/mn-invasive/{z}/{x}/{y}.grid.json'
]; ];
*/


// Move attributioin to footnotes // Move attributioin to footnotes
map.attributionControl.setPrefix(''); map.attributionControl.setPrefix('');
$('.footnote').html($('.footnote').html() + ' ' + map.attributionControl._container.innerHTML); $('.footnote').html($('.footnote').html() + ' ' + map.attributionControl._container.innerHTML);
map.removeControl(map.attributionControl); map.removeControl(map.attributionControl);


// Add layer and interaction // Add layer and interaction
map.addLayer(new wax.leaf.connector(tilejson)); map.addLayer(new wax.leaf.connector(tilejson));
Expand Down

0 comments on commit 1c8fc9b

Please sign in to comment.