Skip to content

Commit

Permalink
load initial zoom,lat,lon from config
Browse files Browse the repository at this point in the history
  • Loading branch information
embeepea committed Oct 20, 2020
1 parent 65757b8 commit 1595965
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 1595965

Please sign in to comment.