3D地球交互地图

原理

采用openglobus

代码

<html>
<head>
    <title>OpenGlobus - Earth planet</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="http://www.openglobus.org/og.css" type="text/css" />
    <script src="http://www.openglobus.org/og.js"></script>
</head>
<body>
    <div id="globus" style="width:100%;height:100%"></div>
    <script>

    pointLayer = new og.layer.Vector("points", {
        'groundAlign': true,
        'entities': [{
            'name': 'Blue Marker',
            'lonlat': [8.19, 46.73],
            'billboard': {
                'src': 'marker.png',
                'size': [29, 48],
                'offset': [0, 24]
            }
        }, {
            'name': 'label',
            'lonlat': [8.25, 46.74],
            'label': {
                'text': 'Touch me',
                'size': [35],
                'outlineColor': "rgba(0,0,0,.5)"
            }
        }],
        'async': false
    });

    var osm = new og.layer.XYZ("OpenStreetMap", {
        specular: [0.0003, 0.00012, 0.00001],
        shininess: 20,
        diffuse: [0.89, 0.9, 0.83],
        isBaseLayer: true,
        //https://webst02.is.autonavi.com/appmaptile?style=6&x=107860&y=49585&z=17
        //url: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
        url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
        visibility: true,
        attribution: 'Data @ OpenStreetMap contributors, ODbL'
    });

    globus = new og.Globus({
        "target": "globus",
        "name": "Earth",
        "terrain": new og.terrainProvider.TerrainProvider("OpenGlobus")
        ,"layers": [osm]
    });

    /**
    var pickingObject = null;
    var startClick = new og.math.Vector2(),
        startPos;

    pointLayer.events.on("mouseenter", function (e) {
        globus.planet.renderer.handler.gl.canvas.style.cursor = "pointer";
    });

    pointLayer.events.on("mouseleave", function (e) {
        globus.planet.renderer.handler.gl.canvas.style.cursor = "default";
    });

    pointLayer.events.on("ldown", function (e) {
        globus.planet.renderer.controls[0].deactivate();

        startClick.set(e.x, e.y);
        pickingObject = e.pickingObject;
        startPos = globus.planet.getPixelFromCartesian(pickingObject.getCartesian());
    });

    pointLayer.events.on("lup", function (e) {
        globus.planet.renderer.controls[0].activate();
        pickingObject = null;
    });

    globus.planet.renderer.events.on("mousemove", function (e) {
        if (pickingObject) {
            var d = og.math.vector2(e.x, e.y).sub(startClick);
            var endPos = startPos.add(d);
            var coords = globus.planet.getCartesianFromPixelTerrain(endPos);
            if (coords) {
                pickingObject.setCartesian3v(coords);
            }
        }
    });
*/
    globus.planet.viewExtentArr([8.08, 46.72, 8.31, 46.75]);

    </script>
</body>
</html>

 

效果

 

分析

 性能上,CPU一直在用,即使没有交互操作

转载于:https://www.cnblogs.com/lilei2blog/p/8743055.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值