我有这个 kml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>CDATA example</name>
<description>
<![CDATA[
<h1>CDATA Tags are useful!</h1>
<p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.</font></p>
]]>
</description>
<Point>
<coordinates>102.595626,14.996729</coordinates>
</Point>
</Placemark>
</Document>
</kml>
(来自谷歌地图文档的示例)当我将一个类添加到 KML 内的 href 时:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>CDATA example</name>
<description>
<![CDATA[
<h1>CDATA Tags are useful!</h1>
<p><font color="red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
references.<a class="read_more" href="http://google.com">Read More</a></font></p>
]]>
</description>
<Point>
<coordinates>102.595626,14.996729</coordinates>
</Point>
</Placemark>
</Document>
</kml>
KMl 只是剥离它我猜这是由于“内容清理” https://developers.google.com/earth/documentation/balloons
这是我当前的 javascript:
jQuery(document).ready(function($) {
function initialize() {
var myLatlng = new google.maps.LatLng(51.201465,-0.30244);
var mapOptions = {
zoom: 12,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var kmlLayer = new google.maps.KmlLayer({
url: 'http://*****.com/new/wp-content/themes/required-starter/KML_Samples.kml?rand='+(new Date()).valueOf(),
suppressInfoWindows: false,
map: map
});
google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
alert(text);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
});
我找不到正确的参数来停止数据清理或 kml 文档中的选项以将类添加到描述包装器或气泡中。我想这是由于我的无能,请帮助!克里斯