Coder Social home page Coder Social logo

leaflet.animatedmarker's Introduction

Leaflet Animated Marker

沿轨迹带方向的动态marker,查看 在线示例

如何使用

参考如下代码,即可实现动态marker绘制,并动态绘制已行走轨迹。

var carIcon = L.icon({
    iconSize: [37, 26],
    iconAnchor: [19, 13],
    iconUrl: '../img/car.png'
})
// 动态marker
var animatedMarker = L.animatedMarker(routeLine.getLatLngs(), {
    icon: carIcon,
    playCall: updateRealLine
}).addTo(map)
var newLatlngs = [routeLine.getLatLngs()[0]]

// 绘制已行走轨迹线(橙色那条)
function updateRealLine(latlng) {
    newLatlngs.push(latlng)
    realRouteLine.setLatLngs(newLatlngs)
}

播放状态控制

// 开始
function startClick() {
    animatedMarker.start();
}

// 暂停
function pauseClick() {
    animatedMarker.pause();
}

// 停止
function stopClick() {
    newLatlngs = []
    animatedMarker.stop();
}

let speetX = 1 // 默认速度倍数
// 加速
function speetUp() {
  speetX = speetX * 2
  animatedMarker.setSpeetX(speetX);
}

// 减速
function speetDown() {
  speetX = speetX / 2
  animatedMarker.setSpeetX(speetX);
}

参考链接

https://github.com/openplans/Leaflet.AnimatedMarker

https://github.com/mohsen1/leaflet-moving-marker

leaflet.animatedmarker's People

Contributors

eternity-xyf 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.