Skip to content

stop() does not work for me. #50

@astridx

Description

@astridx

Hello.

Thank you very much for the animated marker plugin for leaflet js.

I am not sure if it a bug, but the function stop() does not work for me? Do I make a mistake?

This is my code example:

`
<!DOCTYPE HTML>
<html lang="de">
<head>
<meta charset="utf-8"/>
<title>Eine OSM Karte mit Leaflet</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"&gt;&lt;/script>
<script src="AnimatedMarker.js"></script>
</head>
<body>
<button onclick="start()">Start</button>
<button onclick="stop()">Stop</button>
<div style="height: 700px;" id="mapid"></div>
<script>
var mymap = L.map('mapid', {doubleClickZoom:false}).setView([50.27264, 7.26469], 9);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(mymap);
/*
var line = L.polyline(
[[50.68510, 7.94136],[50.68576, 6.94149],[51.68649, 6.94165]]),
animatedMarker = L.animatedMarker(line.getLatLngs());*/

var line = L.polyline(
[[50.68510, 7.94136],[50.68576, 6.94149],[51.68649, 6.94165]]),
animatedMarker = L.animatedMarker(line.getLatLngs(), {
autoStart: false,
distance: 200, // meters
interval: 1000, // milliseconds
});

mymap.addLayer(animatedMarker);

function start(){animatedMarker.start();}
function stop(){animatedMarker.stop();}

</script>

</body>
</html>
`

Thanks
Astrid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions