Google Earthの.kml(xml)ファイルを取得し、そのコンテンツを使用してGoogleマップにマーカーを配置しています。私が興味を持っている特定のXMLタグは次のようになります。
<Placemark>
<name>Bahamas-LSI</name>
<description><![CDATA[
<img src="http://coralreefwatch.noaa.gov/satellite/ge/data/current/vs_Bahamas_LSI.bmp">
<p>
- <a href="http://coralreefwatch.noaa.gov/satellite/virtual_stations/greater_caribbean.html#Bahamas_LSI">
SST/DHW time series</a>.
<p>
- E-mail coralreefwatch@noaa.gov to subscribe free<br>automatic e-mail bleaching alert for this site.
]]></description>
<Snippet></Snippet>
<LookAt>
<longitude>-76.5000</longitude>
<latitude>23.5000</latitude>
..
</Placemark>
次のコードは名前と緯度と経度を抽出しますが、jQueryを使用してdescriptionタグからCDATAを抽出する方法がわかりません。実際のhtmlを抽出して、Googleマップマーカーの情報ウィンドウで使用できるようにしたいと思います。
//
jQuery.get("CRWGE_current_products.kml", {}, function(data) {
// for each placemark tag, extract the name & latlong
// and then plot
jQuery(data).find("placemark").each(function() {
var station = jQuery(this);
var name = station.find('name').text();
var latlng = new google.maps.LatLng(parseFloat(station.find('latitude').text()),
parseFloat(station.find('longitude').text()));
// get html for station-specific data
var content = station.find('description').text();
console.log(content); <--- empty string
setMarker(map, latlng, name, stressIcon, content)
});
});