GithubHelp home page GithubHelp logo

shuidibeida / drawhelper-with-cesium-v1.41 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leation/drawhelper-with-cesium-v1.41

0.0 1.0 0.0 4.47 MB

drawhelper-with-cesium-v1.41,在原cesium-drawhelper基础上,修改了DrawHelper.js部分地方,从而能够支持最新的cesium v1.41

Home Page: http://www.swhztech.com

License: Apache License 2.0

CSS 2.46% JavaScript 95.65% HTML 1.89%

drawhelper-with-cesium-v1.41's Introduction

1、在原cesium-drawhelper基础上,修改了DrawHelper.js部分地方,从而能够支持最新的cesium v1.41,具体修改说明如下:
2、294行
lineWidth: Math.min(this.strokeWidth || 4.0, context._aliasedLineWidthRange[1])
改为:
lineWidth: 1.0
3、977行开始

  
	function updateExtent(value) {
        if (extent == null) {
            extent = new Cesium.RectanglePrimitive();
            extent.asynchronous = false;
            primitives.add(extent);
        }
        extent.rectangle = value;
        // update the markers
        var corners = getExtentCorners(value);
        // create if they do not yet exist
        if (markers == null) {
            markers = new _.BillboardGroup(_self, defaultBillboard);
            markers.addBillboards(corners);
        } else {
            markers.updateBillboardsPositions(corners);
        }
    }

    // Now wait for start
    mouseHandler.setInputAction(function (movement) {
        if (movement.position != null) {
            var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
            if (cartesian) {
                if (extent == null) {
                    // create the rectangle
                    firstPoint = ellipsoid.cartesianToCartographic(cartesian);
                    var value = getExtent(firstPoint, firstPoint);
                    updateExtent(value);
                } else {
                    _self.stopDrawing();
                    if (typeof options.callback == 'function') {
                        options.callback(getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian)));
                    }
                }
            }
        }
    }, Cesium.ScreenSpaceEventType.LEFT_DOWN);

    mouseHandler.setInputAction(function (movement) {
        var position = movement.endPosition;
        if (position != null) {
            if (extent == null) {
                tooltip.showAt(position, "

Click to start drawing rectangle

"); } else { var cartesian = scene.camera.pickEllipsoid(position, ellipsoid); if (cartesian) { var value = getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian)); updateExtent(value); tooltip.showAt(position, "

Drag to change rectangle extent

Click again to finish drawing

"); } } } }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); }

替换为:
  
    // Now wait for start
    mouseHandler.setInputAction(function (movement) {
        if (movement.position != null) {
            var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
            if (cartesian) {
                if (extent == null) {
                    // create the rectangle
                    firstPoint = ellipsoid.cartesianToCartographic(cartesian);
                    var value = getExtent(firstPoint, firstPoint);
                    extent = new _.ExtentPrimitive({
                        extent: value,
                        asynchronous: false,
                        material: options.material
                    });
                    primitives.add(extent);
                    markers = new _.BillboardGroup(_self, defaultBillboard);
		    var corners = getExtentCorners(value);
                    markers.addBillboards(corners);
                } else {
                    _self.stopDrawing();
                    if (typeof options.callback == 'function') {
                        options.callback(getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian)));
                    }
                }
            }
        }
    }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
mouseHandler.setInputAction(function (movement) {
    var position = movement.endPosition;
    if (position != null) {
        if (extent == null) {
            tooltip.showAt(position, "<p>Click to start drawing rectangle</p>");
        } else {
            var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
            if (cartesian) {
                var value = getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian));
                extent.setExtent(value);
	    var corners = getExtentCorners(value);
                markers.updateBillboardsPositions(corners);
                tooltip.showAt(position, "<p>Drag to change rectangle extent</p><p>Click again to finish drawing</p>");
            }
        }
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

}

drawhelper-with-cesium-v1.41's People

Contributors

leation avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.