npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

battletracker-web-renderer

v1.0.1

Published

Web renderer for the Battletracker Arma 3 addon

Downloads

8

Readme

Battletracker Web Renderer

Usage

Install the package by using NPM

 npm install battletracker-web-renderer

The BattleTrackerRenderer class does all of the work of managing where the recording is and displaying all the units on the map. To get it to work what you need to do is:

  • Give it a place to put the map, same as you would do with leaflet.
  • Give it a Recording to play.
  • Tell it which tiles to use, the format is any format leaflet accepts.
  • Cache the unit icons to be used.

Example:

import { BattleTrackerRenderer, Recording } from "battletracker-web-renderer";
import { VehicleType } from "battletracker-web-renderer/lib/VehicleType";
import { VehicleStatus } from "battletracker-web-renderer/lib/VehicleStatus";
import { Side } from "battletracker-web-renderer/lib/Side";
import { IconCache } from "battletracker-web-renderer/lib/IconCache";

const renderer = new BattleTrackerRenderer(document.getElementById("map"));

// Load the file from somewhere like an input tag
const file;
let fileReader = new FileReader();

fileReader.onload = (ev) => {
  renderer.setRecording(Recording.fromArrayBuffer(ev.target.result));
};

// Recordings are binary files that must follow the format specified in
// "Recording.ksy" in the C++ extension repository.
// It is also possible to load them from JSON objects but that has been deprecated.
reader.readAsArrayBuffer(file);

// Tell it where to load the tiles from
renderer.setTileURL("/tiles/chernarus/{z}/{x}/{y}.png");

// By default it does not come with any icons, you need to supply them yourself
// if no icons are supplied it will use the default leaflet marker icon.
// You need to specify icons for each side, vehicle type and status, you can do
// so by using the `createIconsFor` function in the IconCache
IconCache.createIconsFor(
  "/icons/Man-Blufor.png", 
  VehicleType.MAN,
  VehicleStatus.DEFAULT,
  Side.WEST
);

// Due to a limitation in leaflet the icons need to be created for each zoom level
// so if you don't adjust their size, some icons may be too small, like the tank or car icons
// to adjust the size of the icons being created you can use the setIconSizes function
// or you can just get the array and modify it
const iconSizes = IconCache.getIconSizes();
for (let i = 0; i < iconSizes; i++){
  // The index is the leaflet zoom level
  iconSizes[i] = iconSizes[i] + 10;
}

// The tank icons created are now 10px bigger on every zoom level
// than the man icons
IconCache.createIconsFor(
  "/icons/Tank-Blufor.png", 
  VehicleType.TANK,
  VehicleStatus.DEFAULT,
  Side.WEST
);

// Then just start the playback
renderer.play();

The renderer provides some methods to aid in playing back the recording and setting where to start playing from.