mobile
mobile copied to clipboard
Using Javascript in map tips on iPhone
I have a map tip configured in QGIS 3.34 (Windows) that shows elevation data using Javascript.
My point layer has fields x
and y
in EPSG:31255 and retrieves ground elevation using the Austrian Voibos service: https://voibos.rechenraum.com/voibos/voibos?name=hoehenservice&Koordinate=56920,318950&CRS=31255
<table>
<tr><td>Elevation:</td><td id="elev"></td></tr>
</table>
<script>
function roundToTwo(num) {
return +(Math.round(num + "e+2") + "e-2");
}
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
getJSON('https://voibos.rechenraum.com/voibos/voibos?name=hoehenservice&Koordinate=[% x %],[% y %]&CRS=31255',
function(err, data) {
if (err == null) {
document.getElementById("elev").innerHTML = data.hoeheDTM.toFixed(2).concat('m');
}
});
</script>
Is there any chance to get this running in Mergin Maps on iPhone, or can I use a custom Python expression function to solve my issue?