Click here to Skip to main content
13,558,743 members
Rate this:
Please Sign up or sign in to vote.
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

<?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="">
        <name>Placemark2 from KML file</name>
        <name>Placemark2 from KML file</name>

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="//"></script>
<script type="text/javascript">
    var ge;
    var placemark;
    var object;
    google.load("earth", "1");
    function init() {'map3d', initCB, failureCB);
    function initCB(instance) {
        ge = instance;
        var kmlString = ''
                        + '<?xml version="1.0" encoding="UTF-8"?>'
                        + '<kml xmlns="">'
                        + '<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);
    function failureCB(errorCode) {
<div id="map3d" style="border: 1px solid silver; height: 400px; width: 600px;">

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?
Posted 2-Feb-12 0:36am
Shahdat Hosain 2-Feb-12 7:18am
Yap, I have good idea

"By specifying altitude as 100 in your kml,onload google earth display -122.448425,36.802907 placemark with altitude as 100.So,increase your altitude then you can view all your placemarks.I tried in my machine with altitude as 1000000 .Two placemarks are visible onload of google earth."

For more details , see

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180515.1 | Last Updated 2 Feb 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100