话不多说,先看效果图:
示例地址:http://www.bigemap.com/offlinemaps/gl/osgb_demo.html#
源代码:
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'/>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
<link href='http://bigemap.com:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css' rel='stylesheet'/>
<script src='http://bigemap.com:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js'></script>
<style>
body {
margin: 0;
padding: 0;
}
#container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
<title>part_test</title>
</head>
<body>
<div id='container'></div>
<script>
bmgl.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);
});
</script>
</body>
</html>