Click here to Skip to main content
15,888,212 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have a HTML document shown below. When i browse this page there is Error related to NPObject and Earth Does not move to the Location.
But When i load same kml using Google Earth, it moves to the location and placemarks,polylines etc are displayed.
Please Help Stuck with it.

HTML
<!DOCTYPE html>
<html>
<head>
    <title>Google Earth</title>
</head>
<body>
    <form   runat="server">
        <script type='text/javascript' src='https://www.google.com/jsapi'></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);
                ge.getOptions().setStatusBarVisibility(true);
                ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
                ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
                ge.getOptions().setFlyToSpeed(parseFloat("1"));
                LocateGeoLocations();
            }
            function failureCB(errorCode) { }
            function LocateGeoLocations() {
                var kmlString = '<kml xmlns="http://www.opengis.net/kml/2.2"><document><placemark><name>placemark1</name><Style><iconstyle><icon><href>http://www.clker.com/cliparts/X/g/3/n/k/s/pin-point-location-marker-purple-hi.png</href></icon></iconstyle></Style><point><coordinates>-119.448425,37.802907,0</coordinates></point></placemark><placemark><name>placemark2</name><Style><iconstyle><icon><href>http://www.clker.com/cliparts/X/g/3/n/k/s/pin-point-location-marker-purple-hi.png</href></icon></iconstyle></Style><point><coordinates>-120.448425,47.802907,0</coordinates></point></placemark><placemark><name>placemark3</name><Style><iconstyle><icon><href>http://www.clker.com/cliparts/X/g/3/n/k/s/pin-point-location-marker-purple-hi.png</href></icon></iconstyle></Style><point><coordinates>-112.448425,46.802907,0</coordinates></point></placemark><placemark><name>placemark4</name><point><coordinates>-107.448425,43.802907,0</coordinates></point></placemark><placemark><name>placemark5</name><Style><iconstyle><icon><href>http://www.clker.com/cliparts/X/g/3/n/k/s/pin-point-location-marker-purple-hi.png</href></icon></iconstyle></Style><point><coordinates>-115.448425,43.802907,0</coordinates></point></placemark><placemark><name>placemark6</name><point><coordinates>-117.448425,36.802907,0</coordinates></point></placemark><placemark><name>placemark7</name><point><coordinates>-114.448425,33.802907,0</coordinates></point></placemark><placemark><name>placemark8</name><point><coordinates>-109.448425,48.802907,0</coordinates></point></placemark><placemark><name>placemark9</name><description>agdam bagdam</description><point><coordinates>-112.448425,44.802907,0</coordinates></point></placemark><placemark><name>placemark10</name><point><coordinates>-106.448425,44.802907,0</coordinates></point></placemark><placemark><Style><linestyle><color>FF0000FF</color><width>5.0</width></linestyle><polystyle><color>7fff00ff</color></polystyle></Style><linestring><altitudemode>relative to ground</altitudemode><coordinates>-114.448425,33.802907,0 -117.448425,36.802907,0</coordinates></linestring></placemark><placemark><Style><linestyle><color>FF0000FF</color><width>5.0</width></linestyle><polystyle><color>7fff00ff</color></polystyle></Style><linestring><altitudemode>relative to ground</altitudemode><coordinates>-117.448425,36.802907,0 -119.448425,37.802907,0</coordinates></linestring></placemark><placemark><Style><linestyle><color>FF0000FF</color><width>5.0</width></linestyle><polystyle><color>7fff00ff</color></polystyle></Style><linestring><altitudemode>relative to ground</altitudemode><coordinates>-119.448425,37.802907,0 -120.448425,47.802907,0</coordinates></linestring></placemark><placemark><Style><linestyle><color>FF0000FF</color><width>5.0</width></linestyle><polystyle><color>7fff00ff</color></polystyle></Style><polygon><altitudemode>relative to ground</altitudemode><outerboundaryis><linearring><coordinates>-115.448425,43.802907,0 -112.448425,44.802907,0 -112.448425,46.802907,0 -109.448425,48.802907,0 -106.448425,44.802907,0 -107.448425,43.802907,0 -115.448425,43.802907,0 </coordinates></linearring></outerboundaryis></polygon></placemark></document></kml>';
                var kmlObject = ge.parseKml(kmlString);
                ge.getFeatures().appendChild(kmlObject);
                ge.getView().setAbstractView(kmlObject.getAbstractView());
            } google.setOnLoadCallback(init);</script>
        <div id="map3d" style="border: 1px solid silver; height: 550px; width: 800px;">
This is a div to show google Earth
</div>
    </form>
</body>
</html>
Posted
Updated 16-Feb-14 3:56am
v4
Comments
khosla.saurabh 17-Feb-14 2:11am    
Solved this Issue
Member 11097032 9-Oct-14 15:58pm    
i have the same problem, can you tell me how you solved, please

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900