I am looking to create a tooltip that displays attributes from a csv when the user hovers over the feature. What is the easiest way to accomplish this?

For example, if the user hovers above a Gas Main feature, I want the attribute 'Risk Score' for that feature to be displayed in the tooltip window.

I have found many examples of how to create a simple tooltip; however, the example usually displays predefined text that is contained in html. I am looking to display the specific attributes of the feature that the user is hovering above.

  • You should consider setting up a WMS to show your features and use the in built GetFeatureInfo operation to show your tool tip. There are several JavaScript libraries that allow you to work with WMS, and you get the benefit of it it working in desktop GIS too. – nmtoken Aug 31 '18 at 15:39

It sounds like you want to deliver a tip stored in a CSV file to a user who is viewing information in their browser. If so, then this is generally the wrong approach because the browser would need to trigger some sort of AJAX call to retrieve the tip, which is slow and unreliable. That is why most often you'll see the tooltip text embedded in the html where it is readily available.

And that does not prevent you from using values from a CSV file. The common approach is to dynamically generate pages on the server side, often using a templating language to fill in values supplied from a file or database. In this way, the text is not predefined, only a placeholder that is filled in when the request is made and the page delivered.

| improve this answer | |

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.