Skip to content

Commit

Permalink
popups working
Browse files Browse the repository at this point in the history
  • Loading branch information
domlet committed Jan 4, 2024
1 parent 8951a12 commit 5ebce6b
Show file tree
Hide file tree
Showing 8 changed files with 649 additions and 429 deletions.
1,062 changes: 637 additions & 425 deletions books.js

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
5 changes: 4 additions & 1 deletion index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,13 @@
}
console.log(coordinates)
console.log(stateName)
const result = obj.find(obj => {
return obj.state_long === stateName
})
new mapboxgl.Popup()
.setLngLat(coordinates[0][0])
// .setHTML(stateName)
.setHTML(document.getElementsByClassName("mapboxgl-popup-content").innerHTML = '<img src="' + obj[0].img + '" alt="" /><h2>' + obj[0].title + '</h2><br/><p>' + obj[0].author + '</p>')
.setHTML(document.getElementsByClassName("mapboxgl-popup-content").innerHTML = '<img src="' + result.img + '" alt="" /><h2>' + result.title + '</h2><br/><p>' + result.author + '</p>')
.addTo(map);
});

Expand Down
11 changes: 8 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ body {
.mapboxgl-popup {
max-width: 400px;
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
width: 15em;
}

h2 {
margin: 0; padding: 0;
}

p {
margin: 0; padding: 0;
margin: 0.3em 0 0 0; padding: 0;
}

img {
width: 10em;
margin: 1em 0;
width: 6em;
margin: 0.5em;
float: right;
border: 1px solid gray;
border-radius: 0.2em;
filter: drop-shadow(2px 2px #0e0e0e);

}

0 comments on commit 5ebce6b

Please sign in to comment.