如何向 Google 地球气球添加样式

问题描述 投票:0回答:1

如何将 CSS 类/样式添加到通过

createFeatureBalloon()
方法创建的 Google 地球气球?

我已经通过将

.setAttribute("class", "myStyle");
添加到气球对象来尝试此代码,但它似乎在这里不起作用。有没有办法在 Google Earth 中做到这一点?

function showBalloon() {
    var balloon = ge.createFeatureBalloon('div');
    balloon.setFeature(placemark);
    balloon.setAttribute("class", "myStyle");
    balloon.setMaxWidth(600);
    ge.setBalloon(balloon); 
}
google-earth google-earth-plugin
1个回答
0
投票

你应该用以下内容创建一个气球:

var balloon = ge.createHtmlStringBalloon('');

然后用 html 代码创建一个变量,然后使用:

balloon.setContentString(html);

您可以查看https://developers.google.com/earth/documentation/balloons?hl=in

© www.soinside.com 2019 - 2024. All rights reserved.