Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load initial zoom,lat,lon from config; fixes #28 #31

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ APP_HOME_URL: "http://localhost:8000"
SHARED_ASSETS_PATH: "/assets"
TILESERVER_ANTIQUE_JSON: "https://vectortiles.example.org/capabilities/antique.json"
MBGL_TILESERVER_ANTIQUE_JSON: "https://vectortiles.example.org/capabilities/antique.json"
INITIAL_YEAR: "1900"
INITIAL_YEAR: "1940"
INITIAL_ZOOM: "15"
INITIAL_LAT: "40.74096"
INITIAL_LON: "-73.99254"
SITE_NAME: "Kartta Labs"
CONTACT_EMAIL: "[email protected]"
6 changes: 3 additions & 3 deletions mbgl-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const updatePageUrl = (params) => {
document.addEventListener("DOMContentLoaded", function(){
const params = (new URL(document.location)).searchParams;

let currentYear = params.has("year") ? parseInt(params.get("year")) : "1940";
let currentYear = params.has("year") ? parseInt(params.get("year")) : "{{ INITIAL_YEAR }}";

const styleURL = '{{ APP_HOME_URL }}/mbgl-antique-style.json';

Expand All @@ -116,8 +116,8 @@ document.addEventListener("DOMContentLoaded", function(){
const map = new mapboxgl.Map({
container: 'map', // container id
style: styleURL, // stylesheet location
center: [-73.99,40.74], // starting position [lng, lat]lng: -73.99931073493184, lat: 40.74364982242477
zoom: 14,
center: [{{ INITIAL_LON }}, {{ INITIAL_LAT }}],
zoom: {{ INITIAL_ZOOM }},
minZoom: 0,
hash: true,
fadeDuration: 100, //controls the duration of the fade for text labels and symbols (default 300)
Expand Down