1

我正在为街景查看器使用KRPano插件。当我单击它时,我<hotspot>需要显示一个带有值的工具提示。我需要从 JS 函数中获取该值。所以我<style>在我的热点中添加了一个:

<style name="styletooltips"
    onclick="exhibit(); set(layer[text].html, get(js(getText()))); "           
/>

我的js功能:

function getText()
{
    return "Hello World!";
}

我尝试过这种方式,但我不断得到null。如果我取出它get之前的js字面意思js(getText())

PD:exhibit()is KRPano动作,显示带有工具提示的图层。

4

1 回答 1

0

我没有经常使用 KRPano,也没有测试 atm 的环境,但我相信 get 是没有必要的。我相信你只需要这样做:

<style name="styletooltips"
    onclick="exhibit(); set(layer[text].html, js(getText())); "           
/>

如果您查看 KRPano文档,它说 get 将尝试:

Resolve the 'variable' to its value.

在这种情况下,没有使用变量,只是一个方法。您应该安全地调用 js 并使用 return(因为它是字符串文字)。

编辑:我刚刚注意到 get 的参数列表,它对您的实例完全有意义。

variable (Any Variable):
When the variable doesn't exists, then get() will return null.

编辑2:另一种选择是尝试使用该值设置一个变量,然后传递它。例子:

<style name="styletooltips"
    onclick="exhibit(); var item = js(getText()); set(layer[text].html, item)); "           
/>
于 2014-08-28T16:56:22.223 回答