Skip to content

Instantly share code, notes, and snippets.

View dfrho's full-sized avatar

David Rhodes dfrho

View GitHub Profile
@dfrho
dfrho / getBoroView
Created October 20, 2017 18:49
getting the ideal map view for each boro
var boroView = {};
function getBoroView(boroID) {
switch (boroID) {
case 'mh':
boroView = {
boro: 'Manhattan',
coordinates: [-73.952403, 40.793146],
zoom: 10.89
}
function prepNavPanel() {
var boroIDs = ['mh', 'bk', 'qs', 'xb', 'si', 'all']
boroIDs.forEach(function (boroID) {
let buttonEl = document.getElementById(boroID)
let id = buttonEl.id
buttonEl.onclick = id !== 'all' ? function (e) {
e.preventDefault();
filterLocationList(id);
@dfrho
dfrho / dogparks.json
Last active October 20, 2017 19:14
geoJSON feature example
{
"type": "Feature",
"properties": {
"name": "Brooklyn Bridge Dog Run",
"address": "385 Plymouth St",
"boro": "Brooklyn",
"state": "NY",
"DogRuns_Type": "Off-Leash",
"Notes": "Located under the Manhattan Bridge. Go Figure.",
"Prop_ID": "BB999",
@dfrho
dfrho / index.js
Last active November 6, 2017 17:12
flyToBoro and setBoroView
function flyToBoro(view) {
map.flyTo({
center: view.coordinates,
speed: 0.65,
curve: 1.3,
zoom: view.zoom
});
}
var boroView = {};
@dfrho
dfrho / index.js
Created October 20, 2017 19:25
prepNavPanel
function prepNavPanel() {
var boroIDs = ["mh", "bk", "qs", "xb", "si", "all"];
boroIDs.forEach(function (boroID) {
let buttonEl = document.getElementById(boroID);
let id = buttonEl.id;
buttonEl.onclick =
id !== "all"
? function (e) {
@dfrho
dfrho / index.js
Last active November 6, 2017 17:51
new mapboxgl.Map settings
var map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/bubbasdad/cj8krq0rm57zw2sor4hhor04o",
maxZoom: 18,
minZoom: 9,
center: [-73.996, 40.71],
zoom: 9.76,
buffer: 256,
scrollZoom: true,
"source-layer": "nycparks-ad16j1"
@dfrho
dfrho / index.js
Last active November 6, 2017 17:11
flyToRun
function flyToRun(currentFeature) {
map.flyTo({
center: currentFeature.geometry.coordinates,
speed: 0.8,
curve: 1,
zoom: 16
});
}
function flyToBoro(view) {
@dfrho
dfrho / index.js
Created October 20, 2017 19:48
queryRenderedFeatures mapbox gl-js
// set curser to pointer on icon mousehover
map.on("mousemove", function (e) {
var iconsUnderMouse = map.queryRenderedFeatures(e.point, {
layers: ["nycparks-ad16j1"]
});
map.getCanvas().style.cursor = iconsUnderMouse.length ? "pointer" : "";
});
// select icon if clicked on
map.on("click", function (e) {
@dfrho
dfrho / index.js
Created October 20, 2017 21:31
popup with dead link
var sampleFeature = {
type: "Feature",
properties: {
Notes:
"The closest entrance is on Seaman Avenue at Isham Street, and you'll find the run just behind the flag pole. You can reach Inwood Hill Park by Subway via the A train to 207th St, or the 1 train to 207th St, and walk west.",
boro: "Manhattan",
name: "Inwood Hill Park Dog Run: Homer's Run",
Url: "http://www.inwoof.com/",
state: "NY",
address: "Seaman Avenue & Isham Street",
[
{
"id": 1,
"product_name": "Cheese - Pied De Vents",
"product_price": "Dong",
"product_description": "Pellentesque at nulla. Suspendisse potenti. Cras in purus eu magna vulputate luctus.",
"avg_product_review": 2.39,
"in_stock": true,
"product_image": "http://dummyimage.com/150x150.png/5fa2dd/ffffff"
},