-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthew Dangerfield
committed
Oct 16, 2017
1 parent
c5f7777
commit ac61f77
Showing
9 changed files
with
108 additions
and
141 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// See readme for details | ||
exports.config = { | ||
mapsAPIKey: 'YOUR_KEY_HERE', | ||
auth: 'YOUR_FAMILY_SEARCH_AUTHORIZATION_HERE', | ||
cookie: `YOUR_FAMILY_SEARCH_COOKIE_HERE`, | ||
rootPersonId: 'YOUR_FAMILY_SEARCH_PERSON_ID_HERE', | ||
fsAppKey: 'YOUR_APP_KEY_HERE', | ||
fsEnvironment: 'integration or production', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import FamilySearch from 'fs-js-lite' | ||
import promisify from 'es6-promisify'; | ||
|
||
const config = require('../config.js').config | ||
|
||
let fsGet = null | ||
|
||
export function authenticate() { | ||
const fs = new FamilySearch({ | ||
environment: config.fsEnvironment, | ||
appKey: config.fsAppKey, | ||
redirectUri: `${window.location.origin}/authenticated`, | ||
saveAccessToken: true, | ||
requestInterval: 200 | ||
}); | ||
fsGet = promisify(fs.get, fs) | ||
|
||
if (window.location.pathname === '/') { | ||
fs.oauthRedirect() | ||
} else if (window.location.pathname === '/authenticated') { | ||
fs.oauthResponse() | ||
window.location.href = '/map' | ||
} | ||
} | ||
|
||
export function getAncestorInfo() { | ||
return fsGet('/platform/users/current') | ||
.then(res => fsGet(`/platform/tree/ancestry?person=${res.data.users[0].personId}&generations=8`)) | ||
.then(res => { | ||
const personIds = res.data.persons.map(person => person.id) | ||
const idLists = [], maxSize = 450; | ||
|
||
while (personIds.length > 0) { | ||
idLists.push(personIds.splice(0, maxSize)); | ||
} | ||
const getDetailsPromises = idLists.map(idList => fsGet(`/platform/tree/persons?pids=${idList.join(',')}`)) | ||
return Promise.all(getDetailsPromises) | ||
}) | ||
.then(results => { | ||
const persons = [].concat(...results.map(res => res.data.persons)) | ||
const promises = [] | ||
|
||
const simplifiedPersons = persons.map(person => { | ||
const burialInfo = person.facts.find(fact => fact.type.includes("Burial")) | ||
|
||
const simplifiedPerson = { | ||
name: person.display.name, | ||
id: person.id, | ||
gender: person.display.gender, | ||
lifespan: person.display.lifespan, | ||
burialDate: burialInfo && burialInfo.date && burialInfo.date.normalized[0].value, | ||
} | ||
|
||
const burialPlaceDesc = burialInfo && burialInfo.place && burialInfo.place.description | ||
if (burialPlaceDesc) { | ||
promises.push( | ||
fsGet(`/platform/places/description/${burialInfo.place.description.slice(1)}`) | ||
.then(res => { | ||
const placeInfo = res.data.places[0] | ||
simplifiedPerson.burialPlace = { lat: placeInfo.latitude, lng: placeInfo.longitude } | ||
}) | ||
) | ||
} | ||
|
||
return simplifiedPerson | ||
}) | ||
|
||
return Promise.all(promises) | ||
.then(() => simplifiedPersons) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,37 @@ | ||
document.body.innerHTML = require('./map.html'); | ||
const loadGoogleMapsAPI = require('load-google-maps-api'); | ||
const people = require('./getData/peopleWithBurialInfo.json'); | ||
import loadGoogleMapsAPI from 'load-google-maps-api' | ||
import { authenticate, getAncestorInfo } from './familySearch.js' | ||
|
||
document.body.innerHTML = `<div id="map" style="width: 100vw; height: 100vh"></div>` | ||
const people = [] | ||
const apiKey = require('../config.js').mapsAPIKey; | ||
|
||
loadGoogleMapsAPI({ | ||
key: apiKey | ||
}).then(googleMaps => { | ||
const map = new googleMaps.Map(document.getElementById('map'), { | ||
zoom: 3, | ||
center: { lat: 0, lng: 0 } | ||
}); | ||
|
||
people.filter(p => p).forEach(person => { | ||
const marker = new googleMaps.Marker({ | ||
position: person.burialPlace, | ||
map: map | ||
authenticate() | ||
getAncestorInfo() | ||
.then(ancestors => { | ||
people.push(...ancestors) | ||
return loadGoogleMapsAPI({ key: apiKey }) | ||
}) | ||
.then(googleMaps => { | ||
const map = new googleMaps.Map(document.getElementById('map'), { | ||
zoom: 3, | ||
center: { lat: 0, lng: 0 } | ||
}); | ||
|
||
const personInfo = `<h1>${person.name}</h1> | ||
people.filter(p => p).forEach(person => { | ||
const marker = new googleMaps.Marker({ | ||
position: person.burialPlace, | ||
map: map | ||
}); | ||
|
||
const personInfo = `<h1>${person.name}</h1> | ||
<h2><em>${person.lifespan}</em></h2> | ||
<div> | ||
<a href="https://www.familysearch.org/tree/person/${person.id}/details"> | ||
Family Search Link | ||
</a> | ||
</div>`; | ||
const infowindow = new googleMaps.InfoWindow({ content: personInfo }); | ||
marker.addListener('click', () => infowindow.open(map, marker)); | ||
const infowindow = new googleMaps.InfoWindow({ content: personInfo }); | ||
marker.addListener('click', () => infowindow.open(map, marker)); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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