1

I have a map which currently shows one feature of a layer in an overlay popup when you click on it, as per this JSFiddle.

As you can see, it currently displays the address within the overlay. I am looking to show the 'address' and 'name' features within the same overlay, presumably by adding in feature requests.

Also, if possible this will go into a table within the overlay? However I'm not sure where I enter the code for a to go into the overlay popup.

1

Try:

var html = feature.get('address');
html += feature.get('name');
html += feature.get('whatever');

content.innerHTML = html;
popup.setPosition(coord);

UPDATE:

If you want some markup in the popup:

var html = '<h3>Here is ' + feature.get('name') + '</h3>';
html += 'And if you need some <button id="" onclick="">click</button>';

Got it? It's up to you.

  • Thanks @Jonatas, that gives the result below, so it works! But, how would i go about splitting this up into something a bit more user friendly, ideally i'd like to add in a table with buttons in there, i'm unsure where I edit for that to work? jsfiddle.net/joshuadickerson92/86qvt32b/2 – Joshua Dickerson Jun 2 '15 at 20:37
  • You can put whatever you want into this html variable. See updated answer. – Jonatas Walker Jun 3 '15 at 9:28
  • Thanks, I'd actually just worked this out as per the link below. The only issue I have now is if I have two points in the same location. As you can see with Birmingham, when you click on the point it only brings up the value of the point on top, ideally I would like it to show the values of any points that are in this location? jsfiddle.net/joshuadickerson92/86qvt32b/6 – Joshua Dickerson Jun 3 '15 at 9:31
  • Oh, but this is another question. This can be useful to others so create another one. – Jonatas Walker Jun 3 '15 at 9:43
  • Thanks, will do, I've done it in the past but not within an Overlay like this so think it will be different. – Joshua Dickerson Jun 3 '15 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.