GithubHelp home page GithubHelp logo

dabiaoluo / cesium-draw Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xtfge/cesium-draw

0.0 1.0 0.0 100.84 MB

This is a Vue + Cesium project. Its main functions include plotting and editing marker, polyline and polygon.

License: Apache License 2.0

JavaScript 52.38% HTML 0.35% Vue 35.59% CSS 9.61% SCSS 2.06%

cesium-draw's Introduction

Cesium-Draw

基于Vue开发的Cesium基础标绘插件,支持交互式添加BillBoard、Polyline、Polygon、Label和Model

核心功能:

  • 鼠标交互绘图
  • 对于Billboard、Label、Model支持图标,名称的编辑,图标可以任意扩展.
  • 对于Polyline和Polygon支持顶点、颜色等常见图形属性的编辑.
  • 支持导入、导出功能
  • 可以通过图层管理器管理通过该插件添加的所有图形.

安装

npm i cesium-draw

使用

<template>
    <div>
     <div id='map'></div>
     <cesium-draw ref='drwaManager' :viewer="viewer"></cesium-draw>
    </div>
</template>
<script>
import cesiumDraw from 'cesium-draw'
import 'cesium-draw/dist/theme/default.css'
//import 'cesium-draw/dist/theme/dark.css'
export default{
    name:'your-component',
    data(){
        return {
            viewer:null
        }
    }
    components:{cesiumDraw},
    mounted(){
        this.viewer=new Cesium.Viewer('map')
    }
}
</script>

如果你没有将Cesium Viewer对象保存到Vue data中,你必须显式调用init函数初始化组件。

const viewer=new Cesium.Viewer('map')
this.$refs.drawManager.init(viewer)

怎么扩展标记图标

<cesium-draw ref='drwaManager' :extendMarkerImage="images"></cesium-draw>
data(){
    return{
        images:["./static/images/markers/1.png",
                "./static/images/markers/2.png",
                "./static/images/markers/3.png",
                "./static/images/markers/4.png",
                "./static/images/markers/5.png"
      ]
    }
}

怎么使用模型标记

你必须通过extendMarkerModel属性定义用于标记的模型,才可以使用模型标记。

比如:

<cesium-draw ref='drwaManager' :extendMarkerModel="model"></cesium-draw>
data(){
    return{
        model:[
            { id: "model0", 
            name: "tower", 
            thumb:'thumb.png',
            url: "static/model/Wood_Tower.gltf" },
          { 
              id: "model1", 
              name: "people", 
              url: "static/model/Cesium_Man.gltf" }]
    }
}

如何使用喜欢的主题

import 'cesium-draw/dist/theme/default.css' 

import 'cesium-draw/dist/theme/dark.css'

更多主题敬请期待。

示例

<template>
  <div>
   <div id='map'></div>
   <cesium-draw ref='drwaManager' :extendMarkerImage="images" :extendMarkerModel='model' ></cesium-draw>
 </div>
</template>
<script>
import cesiumDraw from 'cesium-draw'
//You can use theme
import 'cesium-draw/dist/theme/dark.css'
//import 'cesium-draw/dist/theme/default.css'
export default{
    name:'your-component',
    data(){
        return {
            images:["./static/images/markers/1.png",
                "./static/images/markers/2.png",
                "./static/images/markers/3.png",
                "./static/images/markers/4.png",
                "./static/images/markers/5.png"
                ],
            model:[
                { id: "model0", 
                name: "tower", 
                url: "static/model/Wood_Tower.gltf" },
                { 
                id: "model1", 
                name: "people", 
                url: "static/model/Cesium_Man.gltf"
                }]
        }
    }
    components:{cesiumDraw},
    mounted(){
        const viewer=new Cesium.Viewer('map')
        this.$refs.drawManager.init(viewer)
    }
}
</script>

Methods

  • getById(gvid) 根据id返回图形要素

Events

事件 说明 回调
deleteEvent 要素删除事件 参数为删除要素的id
locateEvent 要素定位事件 定位要素的id
editEvent 要素编辑事件 要素的id
renameEvent 要素重命名事件 两个参数,依次为要素id,要素更新前的名称
selectEvent checkbox点击事件 两个参数,依次为要素id,checkbox状态
closeEvent 标绘面板关闭事件

开发&打包

npm install
npm run build

打包成组件

npm run lib

效果

avatar avatar

cesium-draw's People

Contributors

xtfge avatar

Watchers

James Cloos 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.