Socket
Socket
Sign inDemoInstall

bmap-geojson

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bmap-geojson

基于百度地图生成geojson


Version published
Maintainers
1
Created

Readme

Source

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)

nametyperequiredescription
mapmapobjecttrue当前地图对象
geojsonjsonobjectfalse显示已经绘制完成的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

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

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

close()

结束绘制

Events

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

Keywords

FAQs

Last updated on 01 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc