278 lines
11 KiB
HTML
278 lines
11 KiB
HTML
<html>
|
|
<head>
|
|
<title>NYC Bookstores</title>
|
|
<meta charset='utf-8'>
|
|
<link rel="icon" type="image/png" href="/img/favicon.png" />
|
|
<link rel="apple-touch-icon" href="/img/social.jpg" />
|
|
<script type="text/javascript" src='js/jquery.js'></script>
|
|
<script type="text/javascript" src='js/mustache.js'></script>
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.0/jquery.scrollTo.min.js"></script>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<script src='https://api.mapbox.com/mapbox-gl-js/v0.34.0/mapbox-gl.js'></script>
|
|
<link href='https://api.mapbox.com/mapbox-gl-js/v0.34.0/mapbox-gl.css' rel='stylesheet' />
|
|
<link href="https://fonts.googleapis.com/css?family=Acme|Lato" rel="stylesheet">
|
|
<link media="screen" rel="stylesheet" type="text/css" href="css/site.css">
|
|
<meta name="twitter:card" content="summary" />
|
|
<meta name="twitter:site" content="www.nycbookstores.org" />
|
|
<meta name="twitter:title" content="NYC Bookstores" />
|
|
<meta name="twitter:description" content="A Guide To The Many Independent Bookstores Of New York City" />
|
|
<meta name="twitter:image" content="http://www.nycbookstores.org/img/social.jpg" />
|
|
<meta property="og:url" content="http://www.nycbookstores.org/" />
|
|
<meta property="og:title" content="NYC Bookstores" />
|
|
<meta property="og:description" content="A Guide To The Many Independent Bookstores Of New York City" />
|
|
<meta property="og:image" content="http://www.nycbookstores.org/img/social.jpg" />
|
|
</head>
|
|
<body>
|
|
<div id="wrapper">
|
|
<h1>NYC Bookstores</h1>
|
|
<div>
|
|
<ul class="nav">
|
|
<li><strong>The Many Independent Bookstores of New York City</strong></li>
|
|
<li><a id='viewInfo'>info</a></li>
|
|
<li><a href="https://github.com/nyc-bookstores/nyc-bookstores.github.io" target="_blank">github</a></li>
|
|
<li><a href="http://www.twitter.com/alazyreader" target="_blank">@alazyreader</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="container">
|
|
<div id='map'></div>
|
|
<div id='info'>
|
|
<p>New York City loves its bookstores. We <a href="http://www.nytimes.com/2006/10/15/nyregion/thecity/15book.html" target="_blank">eulogize those that have faded</a> and celebrate when new ventures are launched. And while the historic <a href="http://untappedcities.com/2015/08/26/4th-avenue-the-history-of-nycs-book-row/" target="_blank">Book Row may have passed away in the 80s</a>, there are still plenty of stores dotting the map. Here, I have attempted to map out all of the currently-open general-interest independent booksellers in the city. Any store with regular-ish hours (no appointment-only rare book sellers) is included, as far as I've been able to determine.</p>
|
|
<p>The listings here are kept up-to-date to the best of my ability. However, I make no promises about either the accuracy or reliability of the information. If you spot an error, or I've missed a shop, please let me know by <a href="mailto:delta.mu.alpha@gmail.com" target="_blank">email</a> or <a href="https://www.twitter.com/alazyreader" target="_blank">twitter</a>. Based on the "<a href="https://github.com/jlord/hack-spots" target="_blank">Hack Spots</a>" website by <a href="http://www.twitter.com/jllord" target="_blank">@jllord</a>.</p>
|
|
<p>There are currently <span id="storeCount"></span> stores indexed on this page.</p>
|
|
</div>
|
|
<div id='selected'></div>
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
<div class="container">
|
|
<div id="Stores"></div>
|
|
</div>
|
|
</div><!-- end wrapper -->
|
|
|
|
<script id="Table" type="text/html">
|
|
<table>
|
|
<tr><th class="tHeader">Name</th><th class="tHeader">Address</th></tr>
|
|
{{#rows}}
|
|
<tr id="{{rowNumber}}" class="spotRow">
|
|
<td class="name">{{name}}</td>
|
|
<td>{{address}}, {{city}}</td>
|
|
</tr>
|
|
{{/rows}}
|
|
</table>
|
|
</script>
|
|
|
|
<script id="selectedStore" type="text/html">
|
|
{{#store}}
|
|
<h2>{{name}}</h2>
|
|
<p class="address">{{address}}<p>
|
|
<p class="address">{{city}},NY {{#postcode}} {{postcode}} {{/postcode}}</p>
|
|
<p>
|
|
<a href="https://maps.google.com/maps?q={{name}} {{address}},{{city}},NY" target="_blank">View in Google Maps</a>
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span class="store-details">Events:</span> {{events}}
|
|
<span class="store-details">Café:</span> {{cafe}}
|
|
</li>
|
|
{{#website}}
|
|
<li><a href='{{website}}' target="_blank">{{website}}</a></li>
|
|
{{/website}}
|
|
</ul>
|
|
{{#description}}
|
|
<p class="description">{{description}}</p>
|
|
{{/description}}
|
|
{{/store}}
|
|
</script>
|
|
|
|
<script>
|
|
mapboxgl.accessToken = 'pk.eyJ1IjoiYWxhenlyZWFkZXIiLCJhIjoiY2lucDZhb2JxMHp6MHRxa2pvaTFoOWpuZyJ9.DILGYYxxt7A-A_lHHwp6tQ';
|
|
var map = new mapboxgl.Map({
|
|
container: 'map',
|
|
style: 'mapbox://styles/mapbox/basic-v9',
|
|
center: [-73.957292, 40.729071], // arbitrary center point
|
|
zoom: 10,
|
|
minZoom: 9,
|
|
maxZoom: 17,
|
|
dragRotate: false
|
|
});
|
|
|
|
var popup = new mapboxgl.Popup({
|
|
closeOnClick: false,
|
|
closeButton: false
|
|
});
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
$.getJSON('./stores.json', function(data) {
|
|
data.sort(
|
|
function(a, b) {
|
|
var aname = a.name.toLowerCase();
|
|
var bname = b.name.toLowerCase();
|
|
return aname === bname ? 0 : +(aname > bname) || -1;
|
|
}
|
|
)
|
|
$.each(data, function(key, value) {
|
|
value.rowNumber = key;
|
|
value.slug = slugify(value.name);
|
|
});
|
|
$('#storeCount').html(data.length);
|
|
window.data = data;
|
|
loadMap(data);
|
|
});
|
|
});
|
|
|
|
window.addEventListener("hashchange", function(e){
|
|
updateViewBySlug(e.newURL.split('#')[1]);
|
|
}, false);
|
|
|
|
function updateHash(slug) {
|
|
history.pushState(null, null, "#" + slug);
|
|
}
|
|
|
|
function slugify(str) {
|
|
return str
|
|
.toLowerCase()
|
|
.replace(/é/g,'e')
|
|
.replace(/&/g,' and ')
|
|
.replace(/ /g,'-')
|
|
.replace(/[']+/g,'')
|
|
.replace(/[^\w-]+/g,'-')
|
|
.replace(/-+/g,'-')
|
|
.replace(/^-|-$/g,'');
|
|
}
|
|
|
|
function getStoreBySlug(slug) {
|
|
var ret = false;
|
|
$.each(window.data, function(key, value) {
|
|
if (value.slug === slug) {
|
|
ret = value;
|
|
return false;
|
|
}
|
|
});
|
|
return ret;
|
|
}
|
|
|
|
function updateViewBySlug(slug) {
|
|
if (slug === "info" || slug === undefined) {
|
|
showInfo(false);
|
|
} else {
|
|
var store = getStoreBySlug(slug);
|
|
if (store) {
|
|
updateSelectedStore(store, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
function boundingBox(point) {
|
|
// add some buffer to a point to give the user some leeway
|
|
return [[point.x - 5, point.y - 5], [point.x + 5, point.y + 5]]
|
|
}
|
|
|
|
function updateSelectedStore(store, pushState=false) {
|
|
map.flyTo({center: [store.long, store.lat]});
|
|
|
|
popup.setLngLat([store.long, store.lat])
|
|
.setHTML(store.name)
|
|
.addTo(map);
|
|
|
|
$('#info').hide();
|
|
var template = $('#selectedStore').html();
|
|
var rendered = Mustache.render(template, {store: store});
|
|
$('#selected').html(rendered);
|
|
$('#selected').show();
|
|
if (pushState) {
|
|
updateHash(store.slug);
|
|
}
|
|
}
|
|
|
|
function showInfo(pushState=true) {
|
|
$('#selected').hide();
|
|
popup.remove();
|
|
$('#info').show();
|
|
if (pushState) {
|
|
updateHash('info');
|
|
}
|
|
}
|
|
|
|
function loadMap(data) {
|
|
var geolocate = new mapboxgl.GeolocateControl();
|
|
|
|
var points = [];
|
|
$.each(data, function(key, value) {
|
|
points.push({
|
|
"type": "Feature",
|
|
"geometry": {
|
|
"type": "Point",
|
|
"coordinates": [value.long, value.lat]
|
|
},
|
|
"properties": value
|
|
});
|
|
});
|
|
map.on('load', function () {
|
|
map.addLayer({
|
|
"id": "stores",
|
|
"type": "circle",
|
|
"source": {
|
|
"type": "geojson",
|
|
"data": {
|
|
"type": "FeatureCollection",
|
|
"features": points
|
|
}
|
|
},
|
|
"paint": {
|
|
"circle-radius": 5,
|
|
"circle-color": "#B9FCFC",
|
|
"circle-stroke-width": 2,
|
|
"circle-stroke-color": "#000000"
|
|
}
|
|
})
|
|
map.addControl(new mapboxgl.NavigationControl(), 'top-left');
|
|
if(navigator.geolocation) {
|
|
map.addControl(geolocate, 'top-right');
|
|
}
|
|
updateViewBySlug(window.location.hash.split("#")[1]);
|
|
});
|
|
|
|
map.on('click', function (e) {
|
|
if (!map.getLayer('stores')) { return; }
|
|
|
|
popup.remove();
|
|
// Use queryRenderedFeatures to get features at a click event's point
|
|
var features = map.queryRenderedFeatures(boundingBox(e.point), { layers: ['stores'] });
|
|
// fly to the location of the click event
|
|
if (features.length) {
|
|
var store = features[0];
|
|
// Get coordinates from the symbol and center the map on those coordinates
|
|
updateSelectedStore(store.properties, true);
|
|
}
|
|
});
|
|
|
|
// indicate that the symbols are clickable by changing the cursor style to 'pointer'.
|
|
map.on('mousemove', function (e) {
|
|
if (!map.getLayer('stores')) { return; }
|
|
var features = map.queryRenderedFeatures(boundingBox(e.point), { layers: ['stores'] });
|
|
map.getCanvas().style.cursor = features.length ? 'pointer' : '';
|
|
});
|
|
|
|
geolocate.on('geolocate', function (e) {
|
|
map.setZoom(14);
|
|
popup.setLngLat([e.coords.longitude, e.coords.latitude])
|
|
.setHTML('Current Location')
|
|
.addTo(map);
|
|
});
|
|
|
|
var template = $('#Table').html();
|
|
var rendered = Mustache.render(template, {rows: data});
|
|
$('#Stores').html(rendered);
|
|
$("#Stores tbody tr").not(':first').on("click", function() {
|
|
updateSelectedStore(data[$(this)[0].id], true);
|
|
$(window).scrollTo($("#selected"), 250, {offset: {top: -15}});
|
|
});
|
|
|
|
$('#viewInfo').on("click", showInfo);
|
|
};
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|