<!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%; } .bmgl-widget-credits{display:none} </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', {terrainId: 'bigemap.9af15d8e',mapId:'bigemap.zhongkexingtu'}); //不启用地形遮挡 viewer.scene.globe.depthTestAgainstTerrain=false; var redPolygon = viewer.entities.add({ name: 'Red polygon on surface', polygon: { hierarchy: bmgl.Cartesian3.fromDegreesArray([-115.0, 37.0, -115.0, 32.0, -107.0, 33.0, -102.0, 31.0, -102.0, 35.0]), extrudedHeight:0, material: bmgl.Color.RED } }); var greenPolygon = viewer.entities.add({ name: 'Green extruded polygon', polygon: { hierarchy: bmgl.Cartesian3.fromDegreesArray([-108.0, 42.0, -100.0, 42.0, -104.0, 40.0]), extrudedHeight: 500000.0, material: bmgl.Color.GREEN, closeTop: false, closeBottom: false } }); // var orangePolygon = viewer.entities.add({ name: 'Orange polygon with per-position heights and outline', polygon: { hierarchy: bmgl.Cartesian3.fromDegreesArrayHeights([-108.0, 25.0, 100000, -100.0, 25.0, 100000, -100.0, 30.0, 100000, -108.0, 30.0, 300000]), extrudedHeight: 0, perPositionHeight: true, material: bmgl.Color.ORANGE.withAlpha(0.5), outline: true, outlineColor: bmgl.Color.BLACK } }); //添加一个椭圆 viewer.entities.add({ position:bmgl.Cartesian3.fromDegrees(-115.0, 40.0), ellipse:{ semiMinorAxis:150000,//短半轴 semiMajorAxis:300000,//长半轴 } }); // var bluePolygon = viewer.entities.add({ name: '带泂多边形', polygon: { hierarchy: { positions: bmgl.Cartesian3.fromDegreesArray([-99.0, 30.0, -85.0, 30.0, -85.0, 40.0, -99.0, 40.0]), holes: [{ positions: bmgl.Cartesian3.fromDegreesArray([ -97.0, 31.0, -97.0, 39.0, -87.0, 39.0, -87.0, 31.0 ]), holes: [{ positions: bmgl.Cartesian3.fromDegreesArray([ -95.0, 33.0, -89.0, 33.0, -89.0, 37.0, -95.0, 37.0 ]), holes: [{ positions: bmgl.Cartesian3.fromDegreesArray([ -93.0, 34.0, -91.0, 34.0, -91.0, 36.0, -93.0, 36.0 ]) }] }] }] }, material: bmgl.Color.BLUE.withAlpha(0.5), height: 0, outline: true // 显示外边框 } }); // var cyanPolygon = viewer.entities.add({ name: '带边框的多边形', polygon: { hierarchy: bmgl.Cartesian3.fromDegreesArrayHeights([ -90.0, 41.0, 0.0, -85.0, 41.0, 500000.0, -80.0, 41.0, 0.0 ]), perPositionHeight: true, material: bmgl.Color.CYAN.withAlpha(0.5), outline: true, outlineColor: bmgl.Color.BLACK } }); viewer.zoomTo(viewer.entities); </script> </body> </html>
源码