-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new client-side filtering demo and update other demos
- Loading branch information
1 parent
d5e8161
commit 664f807
Showing
6 changed files
with
176 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Tilegarden</title> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous"> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script> | ||
<!-- Place this tag in your head or just before your close body tag. --> | ||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<link rel="stylesheet" href="style.css"> | ||
<script> | ||
"use-strict" | ||
|
||
document.addEventListener('DOMContentLoaded', function pageLoaded() { | ||
var map = L.map('map', { | ||
center: [39.97, -75.15], zoom: 11 | ||
}); | ||
|
||
// add basemap | ||
var basemap = L.tileLayer('https://korona.geog.uni-heidelberg.de/tiles/roadsg/x={x}&y={y}&z={z}', { | ||
maxZoom: 19, | ||
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' | ||
}); | ||
map.addLayer(basemap) | ||
|
||
// dynamically set path based on host | ||
var PROD_PATH = 'https://d3hvvzen5hf4hb.cloudfront.net/'; | ||
var DEV_PATH = 'http://localhost:3000/'; | ||
var TILESERVER_PATH; | ||
var host = window.location.hostname; | ||
if (!host || host === 'localhost') TILESERVER_PATH = DEV_PATH; | ||
else TILESERVER_PATH = PROD_PATH; | ||
|
||
// add filtered layers | ||
function newLayer (filters) { | ||
return L.tileLayer(TILESERVER_PATH + 'tile/{z}/{x}/{y}.png?config=data-type-example&layers=' + encodeURIComponent(JSON.stringify(filters))) | ||
} | ||
|
||
var EXAMPLE_PATH = 'https://yourtiles.cloudfront.net/tile/{z}/{x}/{y}.png?layers=' | ||
|
||
var INITIAL_QUERY = [ | ||
{ | ||
name: 'pwd_parcels', | ||
mode: 'AND', | ||
filters: [ | ||
{ | ||
col: 'owner2', | ||
val: 'OF PHILADELPHIA', | ||
}, | ||
{ | ||
col: 'gross_area', | ||
op: '>', | ||
val: '3000' | ||
} | ||
] | ||
} | ||
] | ||
|
||
// keep track of active layers so | ||
var currentSelection; | ||
document.getElementById("btnUpdateQuery").addEventListener('click', function selectorMouseUp() { | ||
// remove old layer | ||
map.removeLayer(currentSelection); | ||
|
||
// get new layer schema | ||
var layerObj; | ||
try { | ||
layerObj = JSON.parse(document.getElementById('querybox').value); | ||
currentSelection = newLayer(layerObj); | ||
currentSelection.addTo(map); | ||
document.getElementById('urlExample').innerText = EXAMPLE_PATH + JSON.stringify(layerObj); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}); | ||
|
||
currentSelection = newLayer(INITIAL_QUERY); | ||
document.getElementById('urlExample').innerText = EXAMPLE_PATH + JSON.stringify(INITIAL_QUERY); | ||
document.getElementById('querybox').value = JSON.stringify(INITIAL_QUERY, null, 2); | ||
map.addLayer(currentSelection); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div class="container content"> | ||
<nav class="navbar navbar-expand-sm navbar-light bg-light"> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<div class="collapse navbar-collapse" id="navbar"> | ||
<ul class="navbar-nav mr-auto"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="../index.html">Home</a> | ||
</li> | ||
<li class="nav-item active dropdown"> | ||
<a class="nav-link dropdown-toggle" href="#" id="demoDropdown" role="button" data-toggle="dropdown"> | ||
Demo | ||
</a> | ||
<div class="dropdown-menu"> | ||
<a class="dropdown-item" href="raster.html">Raster Tiles</a> | ||
<a class="dropdown-item" href="vector.html">Vector Tiles</a> | ||
<a class="dropdown-item" href="layer-filter.html">Queryable Layers</a> | ||
<a class="dropdown-item" href="#">Client-side Filtering</a> | ||
<a class="dropdown-item" href="utf-grid.html">UTF Grids</a> | ||
</div> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="https://github.com/azavea/tilegarden/blob/develop/README.md">Documentation</a> | ||
</li> | ||
</ul> | ||
<a class="navbar-brand" href="https://github.com/azavea/tilegarden/"> | ||
View on GitHub | ||
</a> | ||
<a class="github-button" href="https://github.com/azavea/tilegarden/archive/master.zip" data-icon="octicon-cloud-download" data-size="large" aria-label="Download azavea/tilegarden on GitHub">Download</a> | ||
</div> | ||
</nav> | ||
<div class="mt-3"> | ||
<h2 class="display-4">Filter by Query</h2> | ||
<p class="lead">Allow users to modify pre-defined layers by specifying filter conditions.</p> | ||
<div class="row"> | ||
<div class="m-auto"> | ||
<code id="urlExample">https://yourtiles.cloudfront.net/tile/{z}/{x}/{y}.png?layers=PARK,PRIV</code> | ||
</div> | ||
<div class="col-8"> | ||
<figure class="figure"> | ||
<div id="map" class="figure-img"></div> | ||
<figcaption class="figure-caption" id="dataDesc"> | ||
PWD stormwater billing parcels. The primary purpose of PWD_PARCEL layer is to calculate parcel-based stormwater charges for PWD customers under the new parcel-based stormwater billing program. | <a href="https://www.opendataphilly.org/dataset/pwd-stormwater-billing-parcels">City of Philadelphia</a> | ||
</figcaption> | ||
</figure> | ||
</div> | ||
<div class="col"> | ||
<div class="form-group"> | ||
<label for="querybox">Query schema</label> | ||
<textarea rows="14" id=querybox class="form-control"></textarea> | ||
<div class="w-100 text-right"><button id="btnUpdateQuery" class="btn btn-primary mt-1">Set query</button></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<footer> | ||
<div class="container text-center"> | ||
<span class="text-muted">© 2018 Azavea. Built for the <a href="https://fellowship.azavea.com/">2018 Azavea Open Source Fellowship.</a></span> | ||
</div> | ||
</footer> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters