Created
October 20, 2017 21:31
-
-
Save dfrho/1828b4cdc362568477a48e53e9631f9b to your computer and use it in GitHub Desktop.
popup with dead link
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
var sampleFeature = { | |
type: "Feature", | |
properties: { | |
Notes: | |
"The closest entrance is on Seaman Avenue at Isham Street, and you'll find the run just behind the flag pole. You can reach Inwood Hill Park by Subway via the A train to 207th St, or the 1 train to 207th St, and walk west.", | |
boro: "Manhattan", | |
name: "Inwood Hill Park Dog Run: Homer's Run", | |
Url: "http://www.inwoof.com/", | |
state: "NY", | |
address: "Seaman Avenue & Isham Street", | |
DogRuns_Type: "Run", | |
Accessible: "N", | |
Prop_ID: "M042", | |
postalCode: "10452" | |
}, | |
geometry: { | |
coordinates: [-73.921707, 40.871139], | |
type: "Point" | |
}, | |
id: "149478e1201a8c7aafe14a8133077a91" | |
} | |
// console.log('currentFeature: ', currentFeature); | |
let extLink = currentFeature.properties.Url ? "<a target=\"_blank\" href=\"" + currentFeature.properties.Url + "\">External Link</a>" : "" | |
// console.log('extLink: ', extLink); | |
let popup = new mapboxgl.Popup({ | |
closeOnClick: false, | |
anchor: "top", | |
offset: [0, 20] | |
}) | |
.setLngLat(currentFeature.geometry.coordinates) | |
.setHTML( | |
'<div id="popup" class="mapboxgl-popup"><div><h3>' + | |
currentFeature.properties.name + | |
"</h3>" + | |
"<h4>" + | |
currentFeature.properties.address + | |
"</h4>" + extLink + | |
notesEl + | |
"</div>" | |
) | |
.addTo(map); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment