Code Monkey home page Code Monkey logo

bmap-polylinearrows's Introduction

A BMap plug-in to define and draw patterns on existing Polylines.

百度地图线路自定义方向箭头插件,支持BMap和BMapGL两个版本

index

Usage

BMapGL
let map = new BMapGL.Map('container'); 
map.centerAndZoom(new BMapGL.Point(121.5149319, 31.268328), 17); 
map.enableScrollWheelZoom(true); 

let data = {
    geometry: {
        "type": "MultiLineString",
            "coordinates": [
                [
                    [
                        121.50259791977119,
                        31.234271035048522
                    ],
                    [
                        121.5028609436245,
                        31.234037681240462
                    ]
                ]
            ]
    }
}

let pts = [];
data.geometry.coordinates[0].forEach(coor => {
    pts.push(new BMapGL.Point(coor[0], coor[1]));
})
let polyline = new BMapGL.Polyline(pts, {
     strokeColor: 'blue',
     strokeWeight: 10,
     strokeOpacity: 0.6
});
map.addOverlay(polyline);

let icon = createSingleArrowIcon()
let polylineArrows = new PolylineArrows('BMapGL', map, data, icon, { correctAngle: 90 });

BMap

just replace BMapGL to BMap

Developing

build
npm run build 
npm run build-min
examples
npm run start & http://localhost:3000

API

PolylineArrows constructor options:
Property Type Required Description
mapType String Yes 'BMap' or 'BMapGL'.|支持'BMap'和'BMapGL'两种字符串传入
map Object Yes Map instantiation object.|地图实例化对象
data GeoJSON Yes Polyline data in geojson format.|GeoJSON格式的线数据
icon String Yes Icon for arrow.|箭头图标
opts see below No Options for PolylineArrows. |绘制箭头可选项
opts.step Number No Arrow spacing.|箭头之间的间隔,单位为px
opts.iconSize Number No Arrow icon size.|箭头图标大小,单位为px
opts.correctAngle Number No Arrow icon correction angle.After your icon is corrected, the front of the icon should be aligned horizontally to the right.|箭头图标矫正角度,你的图标需要满足正前方水平朝右,不满足需要矫正

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.