I have a problem of running python script by pressing a HTML button on my Map Tips.

Right now, this is what I've written for my Map Tips in HTML format.

function option1(){
    [% testingFunc('test1') %]
function option2(){
    [% testingFunc('test2') %]

<button onclick="option1()">Option #1</button>
<button onclick="option2()">Option #2</button>

My aim is to allow data input by pressing button that shows up in the Map Tips (http://i.imgur.com/lrzMT6O.png). Each button will run a function named "testingFunc" with different input. Currently, for testing purpose, testingFunc only prints out the input of the function to the console and does nothing else.

Unfortunately, what happens when I hover my mouse over the points (to display the Map Tips,) it ran both scripts immediately and when I pressed the buttons, they don't do anything at all.

I'm guessing this is because the QGIS expression takes precedence while executing that HTML code, but that makes me wonder if what I wanted to do is even possible to begin with?

Your Answer

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

Browse other questions tagged or ask your own question.