2017-01-08 18 views
0

kmlファイルのポップアップバルーンのDescriptionタグ内にGoogle Chart Visualiationのjavascriptコードがあります。グラフはブラウザで正常に表示されますが、Google Earthでは表示されません。 kmlファイルがGoogle Earthで開きますが、ディスプレイに表示されていないグラフは表示されません。なぜこれが機能していないのかわかりません。Google EarthのビジュアリゼーションがGoogle Earthのポップアップで機能しない

は、ここでは、Google Earthでどのように見えるかです:Google Earth Image

例コード:

<?xml version='1.0' encoding='UTF-8'?> 
 
<kml xmlns='http://www.opengis.net/kml/2.2' xmlns:gx='http://www.google.com/kml/ext/2.2' 
 
xmlns:kml='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom'> 
 
<Document> 
 
<name>Chart Test</name> 
 
<Placemark id='ABBEY'> 
 
<Snippet maxLines='0'></Snippet> 
 
<description> 
 
<![CDATA[ 
 
<head> 
 
<style type=text/css> 
 
p {text-align:left; font-family:'Comic Sans MS'; font-size:10pt; line-height:120%; padding:0pt; margin-top:0pt;} 
 
.center {text-align:center;} 
 
.space {margin-top:6pt;} 
 
</style> 
 
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script> 
 
<script type='text/javascript'> 
 
google.charts.load('current', {packages:['corechart']}); 
 
google.charts.setOnLoadCallback(drawChart); 
 
function drawChart() { 
 
var data = google.visualization.arrayToDataTable([ 
 
['Task', 'Hours per Day'], 
 
['Work',  11], 
 
['Eat',  2], 
 
['Commute', 2], 
 
['Watch TV', 2], 
 
['Sleep', 7] 
 
]); 
 
var options = { 
 
title: 'My Daily Activities', 
 
is3D: true, 
 
}; 
 
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); 
 
chart.draw(data, options); 
 
} 
 
</script> 
 
</head> 
 
<div style='height:300px; width:350px; overflow:auto'> 
 
<body> 
 
<table colspan='1'> 
 
<tr> 
 
<td colspan='1' align='center'> 
 
<h2 align='center'>Chart Test</h2> 
 
</td> 
 
</tr> 
 
<tr> 
 
<td colspan='1' align='center'> 
 
<h2>ABBEY</h2> 
 
</td> 
 
</tr> 
 
<tr> 
 
<td colspan='1' align='center'> 
 
<div id='piechart_3d' style='width: 150px; height: 150px;'></div> 
 
</td> 
 
</tr> 
 
<tr> 
 
<td colspan='1' align='center'> 
 
<h3 class='center'>Chart should appear in space above</h3> 
 
</tr> 
 
</table> 
 
</body> 
 
</div> 
 
]]> 
 
</description> 
 
<Point> 
 
<coordinates>-73.059764,44.03325</coordinates> 
 
</Point> 
 
</Placemark> 
 
</Document> 
 
</kml>

この質問は以前に尋ねられましたが、何の回答が掲載されませんでした:https://stackoverflow.com/questions/36936891/google-chart-api-not-working-inside-kml-balloon

感謝あなたの助けに!

答えて

0

Google Earthは、セキュリティ上の目的で、バルーンの説明の中のすべてのjavascriptを削除します。一般的な回避策は、目印(またはより一般的なballoonopeningイベント)のクリックイベントをリッスンし、コンテンツ全体をプログラムでHtmlDivBalloonを再作成することです。詳細については、http://code.google.com/apis/earth/documentation/balloons.html#getballoonhtmlunsafe

+0

あなたのお手伝いをしていただきありがとうございます。投稿したリンクは役に立ちません。 Google Earth APIが使用できなくなったというページに移動するだけです。以前は、URL文字列を使用してグラフを作成するGoogle Chart APIを使用しましたが、私の理解では段階的になっているので、JavaScriptのバージョンを使用する方法を学ぶ必要があります。しかし、目印のクリックイベントを聞いてプログラム上でバルーンを作成する方法を実際に理解するには、初心者の方がはるかに多いです。これについてもっと詳しい情報源があれば、私は最も感謝しています。 –

関連する問題