I would like to show multiple Placemarks by parsing a kml file. Please help, Im stuck for long days. As I see google earth desktop client works well for following kml code snippet
="1.0"="UTF-8"
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Placemark2 from KML file</name>
<Point>
<coordinates>-122.448425,36.802907,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Placemark2 from KML file</name>
<Point>
<coordinates>-122.448425,37.802907,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Based on the above code snippet I tried by following to show multiple placemark at first look. But NO LUCK. I prefer to parse kml string instead of fetching a .kml file, kml file need to be publicly available and reachable by Google. Moreover by parsing kml string we can test it from localhost.
<script src="//www.google.com/jsapi?key=ABQIAAAA5El50zA4PeDTEMlv-sXFfRSsTL4WIgxhMZ0ZK_kHjwHeQuOD4xTdBhxbkZWuzyYTVeclkwYHpb17ZQ"></script>
<script type="text/javascript">
var ge;
var placemark;
var object;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
var kmlString = ''
+ '="1.0"="UTF-8"'
+ '<kml xmlns="http://www.opengis.net/kml/2.2">'
+ '<Document>'
+ '<Placemark>'
+ '<name>Placemark1</name>'
+ '<description>Some Descriptive text.</description>'
+ '<Point>'
+ '<coordinates>-122.448425,36.802907,0</coordinates>'
+ '</Point>'
+ '</Placemark>'
+ '<Placemark>'
+ '<name>Placemark2</name>'
+ '<Point>'
+ '<coordinates>-122.448425,37.802907,0</coordinates>'
+ '</Point>'
+ '</Placemark>'
+ '</Document>'
+ '</kml>';
var kmlObject = ge.parseKml(kmlString);
ge.getFeatures().appendChild(kmlObject);
ge.getView().setAbstractView(kmlObject.getAbstractView());
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
</script>
<div id="map3d" style="border: 1px solid silver; height: 400px; width: 600px;">
</div>
If I add following camera tag in document then one Placemark is shown. All placemark can be shown by zoom out.
+ '<Camera>'
+ '<longitude>-122.448425</longitude>'
+ '<latitude>36.802907</latitude>'
+ '<altitude>100</altitude >'
+ '<tilt>10</tilt>'
+ '<heading>2.7</heading>'
+ '</Camera>'
Have any idea, How can I show mulitple placemark at first look?