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 🙏

© 2025 – Pkg Stats / Ryan Hefner

google-map-dynamic-routing

v1.1.2

Published

A TypeScript-based package for routing and transportation logistics for students and drivers using Google Maps.

Readme

google-map-dynamic-routing

google-map-dynamic-routing is a TypeScript-based service that simplifies the routing and transportation logistics for students and drivers using Google Maps. It dynamically generates routes based on student locations and vehicle capacity, ensuring the most efficient route assignments for drivers.

Installation

This is a Angular module available through the npm registry.

Installation is done using the npm install command:

$ npm install google-map-dynamic-routing

Features

  • Initialize and display Google Maps with school and student locations.
  • Automatically generate and display optimal routes for multiple drivers.
  • Efficiently handle vehicle capacity and distribute students based on proximity.
  • Supports real-time route updates with color-coded routes for each driver.
  • Calculate and log the total distance and duration for each driver’s route.

Docs & Community

Quick Start

To integrate the google-map-dynamic-routing into your Angular application, follow the steps below.

  1. Install the Package First, install the package from npm:
$ npm install google-map-dynamic-routing
  1. Import and Initialize in Angular Component In your Angular component, import the GoogleMapDynamicRouting and use it to set up the map and routing logic.
import { AfterViewInit, Component } from '@angular/core';
import { Assistant, Driver, GoogleMapDynamicRouting, School, Student } from 'google-map-dynamic-routing';
import { environment } from 'src/environments/environment';

@Component({
  selector: 'app-test1',
  templateUrl: './test1.component.html',
  styleUrls: ['./test1.component.scss']
})
export class Test1Component implements AfterViewInit {
  gservice = new GoogleMapDynamicRouting();
  drivers: Driver[] = [];
  assistants: Assistant[] = [];
  schoolId = 2;
  vehicleCapacity = 5;
  mapZoom = 11;

  constructor() { }

  ngAfterViewInit() {
    const mapElement = document.getElementById("map") as HTMLElement;

    // Find school data from environment or use default
    const schoolData = environment.students.find((student) => student.SchoolID === this.schoolId);
    const schoolLocation:School = schoolData ? 
      { location: { lat: schoolData.SchoolLatitude, lng: schoolData.SchoolLongitude }, id: schoolData.SchoolID, name: schoolData.SchoolName } :
      { location: { lat: 51.24435222090445, lng: -0.19657615577176069 }, id: this.schoolId, name: "KP's School" };

    // Filter and map student data
    const students:Student[] = environment.students
      .filter(s => s.SchoolID === this.schoolId)
      .map((s, index) => ({ location: { lat: s.Latitude, lng: s.Longitude }, name: s.FirstName, id: index + 1 }));

    // add the assistant data here(You can make a api call or pass static data)
    const requiredAssistant = Math.ceil(students.length / this.vehicleCapacity);
    for (let i = 1; i <= requiredAssistant; i++) {
      const assistant: Assistant = {
        id: i,
        name: `Assistant-${i}`,
        location: {
          lat: schoolLocation.location.lat + (Math.random() * 0.02 - 0.01),
          lng: schoolLocation.location.lng + (Math.random() * 0.02 - 0.01)
        }
      };

      this.assistants.push(assistant);
    } 

    // Set values for the service
    this.gservice.setValues(schoolLocation, students, [], this.assistants, this.vehicleCapacity, this.mapZoom);

    // Initialize the map
    this.gservice.initMap(mapElement, schoolLocation.location);

    // Generate routes for the drivers
    this.gservice.createRoutesForDrivers();
    this.drivers = this.gservice.drivers;

  }

  getRouteForDriver(driverIndex: number) {
    this.gservice.getRouteForDriver(driverIndex);
  }
}
  1. HTML Template In your component's HTML, create a button for each driver that will show their route when clicked.
<div>
  <button style="margin: 7px;" *ngFor="let driver of drivers; let i = index" (click)="getRouteForDriver(i)">
    Driver {{ i + 1 }}
  </button>
</div>

<!-- Map display -->
<div id="map" style="height: 1000px; width: 100%;"></div>
  1. Fetching School and Student Data via API Instead of storing school and student data in the environment.ts file, you can call an API to retrieve this information dynamically.

  2. Google Maps API Make sure you have set up the Google Maps API correctly in your index.html or in the environment configuration (like an API key) to ensure that the map functions as expected. Example for index.html:

 <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_GOOGLE_MAPS_API_KEY&libraries=places"></script>
  1. Run Your Application Finally, run your Angular app using:
$ ng serve

Visit http://localhost:4200 to see the map with the routes generated for your drivers.