0

I wish to add images and multiple links in a leaflet popup, what should I do and how?

I have already tried by changing .json code array to add multiple links but that does not help me, it just displays the second array variable's link without showing the previous one.

markers = [
   {
     "name": "Canada",
     "url": "https://en.wikipedia.org/wiki/Canada",
     "lat": 56.130366,
     "lng": -106.346771
   },
   {
   "name": "Canada",
   "url":"https://en.wikipedia.org/wiki/Anguilla",
   "lat": 56.130369,
     "lng": -106.346779
   }
}

i expect for the popup to show different different links beneath the popup name.

1 Answer 1

1

You could make an array such as:

 { "name": "Canada", "url": ["https://en.wikipedia.org/wiki/Canada", "https://en.wikipedia.org/wiki/USA"], "lat": 56.130366, "lng": -106.346771 }

and in the popup template just cycle the array with a forEach making a list element for every element in markers.url.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.