-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KML viewer.flyTo placemark goes underground #4327
Comments
"The difference between the two examples appears to be the initial bounding sphere computed for the entity. For the second example, the center of the bounding sphere is identical to the entity's position. Not so with the KML example -- the z-component in particular is much smaller. After the second button click, the bounding sphere gets recalculated and the center becomes roughly the same. " |
This was fixed sometime between 1.26 and 1.27, but I'm not exactly sure by what |
The only reason this appeared fix was because the |
var viewer = new Cesium.Viewer('cesiumContainer');
var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas,
clampToGround: true
};
var zoomTarget;
var kml = '<?xml version="1.0" encoding="utf-8"?>\
<kml xmlns="http://www.opengis.net/kml/2.2">\
<Placemark>\
<name>My office</name>\
<description>This is the location of my office.</description>\
<Point>\
<coordinates>-122.52087481,37.422069</coordinates>\
</Point>\
</Placemark>\
</kml>';
var parser = new DOMParser();
var promise = Cesium.KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options);
Cesium.when(promise, function(dataSource) {
viewer.dataSources.add(dataSource);
zoomTarget = dataSource.entities.values[0];
});
Sandcastle.addToolbarButton('Fly to Placemark', function() {
viewer.flyTo(promise);
}, 'toolbar'); |
Also reported here: https://groups.google.com/d/msg/cesium-dev/9i62vHWn438/NeA5woENCgAJ |
Also reported here: https://groups.google.com/forum/#!topic/cesium-dev/a-m284HtIiA |
To fix this, I think we just need to update |
Will also need to update other visualizers with clamping behavior. |
The original sample with KML is still not working. It is important to instruct users of viewers app viewer.extend(Cesium.viewerCesiumInspectorMixin); var zoomTarget; var kmlFile = "https://raw.githubusercontent.com/ainthek/map-projects/master/data/samples/BMXRaceTracks.googleearthpro.kml.gdal.gpx.gdal.kml"; |
@ainthek I can still reproduce the bug. Until there's a fix, one workaround is to initiate a second flyTo after the first one, which seems to always go to the right location:
Sandcastle. Obviously not ideal to go underground in the first place though. |
@OmarShehata thanx for workaround, but WHY is this magic hack |
@ainthek I replied in your forum thread here about ways you can solve this for your particular use case. |
Here's a workaround that worked for me Get the camera height after function flyToCustom (entity, attempt = 0) {
let hpr = new HeadingPitchRange(CesiumMath.toRadians(0), CesiumMath.toRadians(-90.0), 0)
viewer.flyTo(entity, {duration: 1.0, offset: hpr}).then(() => {
const ellipsoid = viewer.scene.globe.ellipsoid
const height = ellipsoid.cartesianToCartographic(viewer.scene.camera.position).height
if (height < 0 && attempt < 50) { // only attempt 50 times before giving up
flyToCustom(entity, attempt + 1)
}
}
})
} Also, increasing the altitude of the HeadingPitchRange seemed to mitigate the problem |
Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/E27D7WJHWZ8
Using viewer.flyTo for a pin created by this KML file results in the camera going under ground.
Interestingly enough, the same thing does not happen when you create a pin at the same location with the entities API
The text was updated successfully, but these errors were encountered: