话不多说,先看效果图:
源代码:
body {
margin: 0;
padding: 0;
}
#container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
part_testbmgl.Config.HTTP_URL = 'http://bigemap.com:9000';
var viewer = new bmgl.Viewer('container', {});
var tilesets = new bmgl.BM3DTileset({ url:'/bmgl/data/osgb/tileset.json'});
tilesets.readyPromise.then(function(tileset) {
viewer.scene.primitives.add(tileset);
default_HeadingPitchRange = new bmgl.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius * 2.0);
viewer.zoomTo(tileset, default_HeadingPitchRange);
var cartographic = bmgl.Cartographic.fromCartesian(tileset.boundingSphere.center);
var delta_lng=0,delta_lat=0;
var surface = bmgl.Cartesian3.fromRadians(cartographic.longitude+delta_lng, cartographic.latitude+delta_lat, 0.0);
var offset = bmgl.Cartesian3.fromRadians(cartographic.longitude+delta_lng, cartographic.latitude+delta_lat,-41);
var translation = bmgl.Cartesian3.subtract(offset, surface, new bmgl.Cartesian3());
tileset.modelMatrix = bmgl.Matrix4.fromTranslation(translation);
}).otherwise(function(error) {
console.log(error);
});