Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
deyihu-maptalks.routeplayer
Advanced tools
Route Player plugin for maptalks.js.
npm install maptalks
npm install maptalks.routeplayer
<script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/maptalks.routeplayer/dist/maptalks.routeplayer.js"></script>
As a plugin, maptalks.routeplayer must be loaded after maptalks.js in browsers.
<script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/maptalks.routeplayer/dist/maptalks.routeplayer.js"></script>
<script>
const route = [{
coordinate: [120, 31, 0],
time: 301000
},
{
coordinate: [122, 32, 0],
time: 541000
},
//other coordinates
];
const data = maptalks.formatRouteData(route, {});
const player = new maptalks.RoutePlayer(data, {
speed: 4,
debug: false
});
console.log(player);
player.play();
</script>
import {
RoutePlayer,
formatRouteData
} from 'maptalks.routeplayer';
const route = [{
coordinate: [120, 31, 0],
time: 301000
},
{
coordinate: [122, 32, 0],
time: 541000
},
//other coordinates
];
const data = formatRouteData(route, {});
const player = new RoutePlayer(data, {
speed: 4,
debug: false
});
console.log(player);
player.play();
formatRouteData(route,options)
format route data util for RoutePlayer
const route = [{
coordinate: [120, 31, 0],
time: 301000
},
{
coordinate: [122, 32, 0],
time: 541000
},
//other coordinates
];
const data = formatRouteData(route, {});
const route = [{
coord: [120, 31, 0],
t: 301000
},
{
coord: [122, 32, 0],
t: 541000
},
//other coordinates
];
const data = formatRouteData(route, {
coordinateKey: 'coord',
timeKey: 't'
});
const route = [{
coordinate: [120, 31, 0],
},
{
coordinate: [122, 32, 0]
},
//other coordinates
];
const data = formatRouteData(route, {
duration: 1000 * 60 * 10
});
The automatically generated time is milliseconds, by new Date().getTime()
duration unit is milliseconds
RoutePlayer
new RoutePlayer(routeData, options)
formatRouteData
function run resultimport {
RoutePlayer,
formatRouteData
} from 'maptalks.routeplayer';
const route = [{
coordinate: [120, 31, 0],
time: 301000
},
{
coordinate: [122, 32, 0],
time: 541000
},
//other coordinates
];
const data = formatRouteData(route, {});
const player = new RoutePlayer(data, {
speed: 4,
debug: false,
autoPlay: true
});
console.log(player);
player.play();
remove()
add()
play()
pause()
reset()
Restore all states to their original statefunction replay() {
player.reset();
player.play();
}
cancel()
Equivalent to reset
isPlaying()
isPlayend()
finish()
getSpeed()
setSpeed(speed)
It can be analogized to the speed of a videoplayer.setSpeed(10);
setIndex(index)
Set the current playback position to a coordinate nodeplayer.setIndex(10);
setTime(time)
Set the current playback position to a certain time const t = player.getStartTime() / 2 + player.getEndTime() / 2;
player.setTime(t);
setPercent(percent)
Set the current playback position as a percentage of distanceplayer.setPercent(0.3);
setData(data)
reset route dataconst newData = formatRouteData(route, {});
player.setData(data);
getCurrentTime()
getStartCoordinate()
Get the coordinates of the first nodegetStartInfo()
Obtain information about the starting point, including coordinates, rotation information, etc const info = player.getStartInfo();
console.log(info.coordinate);
//for 3d model rotation
console.log(info.rotationZ);
console.log(info.rotationX);
function updateModelPosition(e) {
const {
coordinate,
rotationZ,
rotationX
} = e;
if (!currentModel) {
return;
}
// if (Math.abs(rotationX) > 40) {
// console.log(rotationX);
// }
currentModel.setCoordinates(coordinate);
currentModel.setRotation(rotationX, 0, rotationZ + modelOffsetAngle);
}
currentModel = new maptalks.GLTFMarker(info.coordinate, {
symbol,
});
gltfLayer.addGeometry(currentModel);
updateModelPosition(info)
getData()
getStartTime()
getEndTime()
getUnitTime()
setUnitTime(t)
//if your data time unit is second,1 second= 1000 ms
player.setUnitTime(1000);
getCurrentCoordinate()
Get the coordinates of the current playback pointgetCurrentVertex()
getCoordinates()
player.on('playstart playing playend pause', e => {
console.log(e.type);
})
add
remove
playstart
playing
function updateModelPosition(e) {
const {
coordinate,
rotationZ,
rotationX
} = e;
if (!currentModel) {
return;
}
// if (Math.abs(rotationX) > 40) {
// console.log(rotationX);
// }
currentModel.setCoordinates(coordinate);
currentModel.setRotation(rotationX, 0, rotationZ + modelOffsetAngle);
}
player.on('playing', e => {
if (autoUpdateMapCenter) {
map.setCenter(e.coordinate);
}
updateModelPosition(e);
// point.setCoordinates(e.coordinate);
});
playend
vertex
Passing through coordinate nodes during playbackfunction showVertex(e, vertexs, layer) {
const data = e.data;
const index = e.index;
console.log(index);
if (!vertexs[index]) {
const coordinate = data.coordinate;
const point = new maptalks.Marker(coordinate, {
symbol: {
markerType: 'ellipse',
markerWidth: 5,
markerHeight: 5,
textSize: 12,
textName: index,
textFill: '#fff'
}
});
vertexs[index] = point;
}
const point = vertexs[index];
if (!point.getLayer()) {
point.addTo(layer);
}
const needRemoves = vertexs.slice(index + 1, Infinity);
if (needRemoves.length) {
layer.removeGeometry(needRemoves);
}
}
let vertexs = [];
player.on('vertex', e => {
showVertex(e, vertexs, debugLayer);
});
settime
it will when you setTime/setIndex/setPercentreset
cancel
pause
finish
We welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.
1.0.0-alpha.3
getCoordinates()
method1.0.0-alpha.2
getCurrentVertex()
method1.0.0-alpha.1
FAQs
Route Player plugin for maptalks.js
The npm package deyihu-maptalks.routeplayer receives a total of 2 weekly downloads. As such, deyihu-maptalks.routeplayer popularity was classified as not popular.
We found that deyihu-maptalks.routeplayer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.