Skip to content

Commit

Permalink
Refashion utf grid demo in pug
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdelsordo committed Aug 22, 2018
1 parent 146f349 commit bcaafe0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pug/pages/demo/scripts/L.UTFGrid-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions src/pug/pages/demo/scripts/utf-grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"use-strict"

document.addEventListener('DOMContentLoaded', function pageLoaded() {
var map = L.map('map', {
center: [39.96, -75.15],
zoom: 15,
});

// 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> &mdash; Map data &copy; <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;

L.tileLayer(TILESERVER_PATH + 'tile/{z}/{x}/{y}.png?config=data-type-example&layers=["inlets"]').addTo(map);
var grid = L.utfGrid(TILESERVER_PATH + 'grid/{z}/{x}/{y}?config=data-type-example&layers=["inlets"]&utfFields=owner,operator', { useJsonP: false })

// keep track of currently active marker
//var marker
grid.on('mouseover', function gridClick(e) {
if (e.data) {
L.popup()
.setLatLng(e.latlng)
.setContent("This inlet is owned by " + e.data.owner + " and operated by " + e.data.operator + ".")
.openOn(map)
}
})
map.addLayer(grid);


// prompt user to mouse over the map, remove mouseover div on mouseover
document.getElementById('mousePrompt').addEventListener('mouseover', function onMouseOver() {
this.parentNode.removeChild(this);
})
});
29 changes: 29 additions & 0 deletions src/pug/pages/demo/utf-grid.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends ../../components/layout.pug

block vars
- var pageTitle = 'UTF Grids'

block scripts
include ../../components/leaflet-scripts.pug
script(src='./scripts/L.UTFGrid-min.js')
script(src='./scripts/utf-grid.js')

block content
h2.display-4 UTF Grids
p.lead Serve UTF grids and interact with your data.
.row
.m-auto
code#urlExample https://yourtiles.cloudfront.net/tile/{z}/{x}/{y}.png?utfFields=owner,operator
figure.figure.w-100(style={'position': 'relative'})
.figure-img#map(style={'position': 'absolute', 'z-index': '1'})
.jumbotron.w-100.display-4.text-center#mousePrompt(style={
'position': 'absolute',
'z-index': '2',
'height': '500px',
'opacity': '0.5'
}) Mouse over me!
figcaption.figure-caption#dataDesc(style={'position': 'absolute', 'top': '500px', 'z-index': '3'})
| This point layer contains all the wastewater and stormwater inlets in Philadelphia with latitude and longitude coordinates. |
|
a(href="https://www.opendataphilly.org/dataset/water-inlets") City of Philadelphia

0 comments on commit bcaafe0

Please sign in to comment.