Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The documentation is a bit unclear on that point; it should perhaps say that <code>KmlGeometry</code> objects cannot be <em>instantiated</em> directly. There are, in fact, several methods on a <code>KmlGeometry</code> object, <a href="https://developers.google.com/earth/documentation/reference/interface_kml_geometry-members" rel="nofollow">which you can see in the documentation</a> if you click through the "List of all members" link (the most relevant ones are inherited from <code>KmlObject</code>).</p> <p>All the different geometry types inherit from <code>KmlGeometry</code>, but since you know that this geometry is a <code>KmlPoint</code>, you can just treat it as a <code>KmlPoint</code> (in other languages you might have to explicitly cast the variable, but, for better or worse, Javascript is more forgiving). In your case, you could do</p> <pre><code>var point = pm.getGeometry(); point.setAltitude(newAltitudeValue); point.setLatLng(...); </code></pre> <p>etc. You can use all the <a href="https://developers.google.com/earth/documentation/reference/interface_kml_point" rel="nofollow">normal KmlPoint methods</a>.</p> <p>Incidentally, if you <em>don't</em> know the specific type of geometry (for instance, if the geometry is returned as the target on a click event and could be anything), you can always ask it with <code>getType</code> inherited from <code>KmlObject</code> (in this case, <code>pm.getGeometry().getType()</code> would return <code>'KmlPoint'</code>), which you could then act upon. Not a perfect reflection system, but it works.</p> <p><strong>Addendum:</strong> Your example KML contains the line</p> <pre><code>&lt;altitude&gt;clampedToGround&lt;/altitude&gt; </code></pre> <p>which is not valid KML. What you probably mean is</p> <pre><code>&lt;altitudeMode&gt;clampToGround&lt;/altitudeMode&gt; </code></pre> <p>Earth discards the element it doesn't understand (though a validator will show this error), but it doesn't especially matter in this case, since <code>clampToGround</code> is the default altitudeMode anyway. This is the cause of any altitude changes being dropped, as <code>clampToGround</code> "indicates to ignore an altitude specification" (<a href="https://developers.google.com/kml/documentation/kmlreference#point" rel="nofollow">per the docs</a>), so the point will be placed at ground level regardless of its altitude value.</p> <p>To be able to change the altitude, either change the KML you're feeding it, using <code>relativeToGround</code> or <code>absolute</code> as the altitudeMode, or use the API to change it, e.g.</p> <pre><code>pm.getGeometry().setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND); </code></pre> <p>Then any altitude you set via <code>pm.getGeometry().setAltitude(...)</code> should work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload