Skip to content

Commit

Permalink
refac: add map coordinates using variables
Browse files Browse the repository at this point in the history
Now, the orphanage's coordinates are pulled from the database.
  • Loading branch information
lobophf committed Oct 21, 2020
1 parent 8ff95dc commit 64040a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/scripts/page-orphanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const options = {
zoomControl: false
}

const map = L.map('mapid', options).setView([-27.222633, -49.6455874], 15);
const lat = document.querySelector('span[data-lat]').dataset.lat;
const lng = document.querySelector('span[data-lng]').dataset.lng;

const map = L.map('mapid', options).setView([lat, lng], 15);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',).addTo(map);

Expand All @@ -17,8 +20,7 @@ const icon = L.icon({
popupAnchor: [170, 2]
});

L.marker([-27.222633, -49.6455874], {icon })
.addTo(map)
L.marker([lat, lng], { icon }).addTo(map)

function selectImage(event) {
const button = event.currentTarget
Expand Down

0 comments on commit 64040a0

Please sign in to comment.