Coder Social home page Coder Social logo

bmap-geo's Introduction

bmap-json

基于百度地图生成geojson

依赖

百度地图

使用说明

引入方式

传统引入方式:

<script src="http://api.map.baidu.com/getscript?v=3.0&ak=KAYsf1crZqV9xgyWEzsGpaVzvobclAmu&t=1"></script>
<script src="thirdparty/bmap/bmap-geojson.js"></script>

ES6引入方式

注意,在引用的时候就要确保百度地图已经被加载了。

npm install BmapGeo
import * as BmapGeo from 'bmap-geojson'

调用方式

var geo = new BmapGeo(map, geojson, BMap)

name type require description
map mapobject true 当前地图对象
geojson jsonobject false 显示已经绘制完成的geojson
var map = new BMap.Map('container')
map.centerAndZoom("北京", 12)
map.enableScrollWheelZoom(true)
var geo = new BmapGeo(map)
geo.showControl() // 显示内置控制图标
geo.on('add', function (type, result) { // 元素被添加触发事件
  console.log(result)
})
geo.on('delete', function (type, result) { // 元素被删除触发事件
  console.log(result)
})

Method

showControl()

显示内置绘制控件,目前内置了绘制区域polygon控件和绘制坐标点point控件

open(type)

开始绘制

Parameters

name Type Default description
open type 1 绘制的模式,1表示绘制区域polygon,2表示绘制坐标点point。在不调用showControl()时,可以使用这个方法实现自定义绘制控件。

clear()

清除使用后生成的数据,便于重新使用。

close()

结束绘制

Events

  • on(eventName, callback)
eventName description
add 元素被添加触发事件
delete 元素被删除触发事件
change 元素属性被修改触发,目前只修改name属性

bmap-geo's People

Contributors

towersxu 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.