1

I have a map in QGIS displaying many languages being spoken in the displayed area. Each one of them has a designated marker with a HTML frame that shows up on hover.

Overview

However, in this frame I would like to display data like the ISO-code of that language. This data is stored in a text file that I added to the project via layers.

It contains the X Y coordinates, the language name (displayed on the map) and the ISO-code, each tab separated.

The HTML frame code is this (http://pastebin.com/xZYCk6S0 if it's not working properly):

<!DOCTYPE html>
<html>
<head>
<style>
  #map {
    height: 400px;
    width: 100%;
   }
</style>
</head>
<body>
<div style="width:550;height:550; background-color: lightgrey">
<p><font color="black">Search this ISO code on</font></p> 
<p><font color="blue"><a href="http://wals.info/languoid">WALS</a></font></p>
</div>
<h3>This language is found here:</h3>
<div id="map"></div>
<script>
  function initMap() {
    var uluru = {lat: 50.115017, lng: 8.634350}; 
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 4,
      center: uluru
    });
    var marker = new google.maps.Marker({
      position: uluru,
      map: map
    });
  }
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&callback=initMap">
</script>
</body>
</html>

I haven't found out yet how to reference the data on the map so that the frame would say: "language_name" with ISO-Code "ISO_code" is found here: So that each frame adaptively has the right information in it.

1 Answer 1

1

I have found where to reference data that is stored in text files used by layers: For QGIS 2.18.2, click on the layer that you want to display the HTML iframe on. Select 'properties' and navigate to 'display'. Within the HTML code you can reference data via the 'Insert expression..' option in the bottom left, right underneath your code text box. Like so: Inserting expression

QGIS will now open a window allowing you to insert different expressions into your HTML code. The left column is what you will add to the code (in bottom right there is a preview telling you if it is syntactically correct).

To reference data in your label text file, simply click on 'Fields and Values' in the middle column of the 'Insert Expression' dialogue.

It will now be added to your HTML code in this form: [% NAME_OF_DATA %] [Referencing data used in layers]2

Your Answer

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

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