Skip to content

Instantly share code, notes, and snippets.

Brian Michalski bamnet

Block or report user

Report or block bamnet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View distance_matrix.ts
export class DistanceMatrixService extends google.maps.DistanceMatrixService {
rateLimiter = new RateLimiter(2, 'second');
static readonly maxElements = 100;
async getDistanceMatrixAsync(req: google.maps.DistanceMatrixRequest) {
// If the matrix is too big, we have to split up the requests into smaller chunks.
if (!.length * req.destinations!.length > DistanceMatrixService.maxElements) {
return this.shardedMatrix(req);
View route.ts
async function routeBetween(
directionSvc: import("./modern_services").DirectionService,
parks: Park[]
) {
const waypoints: google.maps.DirectionsWaypoint[] = => ({ location: }));
const req: google.maps.DirectionsRequest = {
origin: 'New York Penn Station',
destination: 'New York Penn Station',
optimizeWaypoints: true,
View park.ts
export async function filterParks(placesSvc: import("./places").PlacesService): Promise<Park[]> {
return Promise.all(ListParks().map((park) => park.findPlace(placesSvc))).then((parks) => {
return parks.filter((park) => park.placeResult!.formatted_address!.includes("New York, NY"));
export class Park {
// Name of the park.
name: string;
View main.ts
let placesSvc: import("./places").PlacesService;
async function initMap() {
const services = await import('./places');
placesSvc = new services.PlacesService(<HTMLDivElement>document.getElementById('attr'));
View places.ts
import { RateLimiter } from 'limiter';
export class PlacesService extends google.maps.places.PlacesService {
rateLimiter = new RateLimiter(2, 'second');
async findPlaceFromQueryAsync(req: google.maps.places.FindPlaceFromQueryRequest) {
await this.waitForToken();
return new Promise(
resolve: (result: google.maps.places.PlaceResult[]) => void,
bamnet / Dockerfile
Created Jan 7, 2019
Multiarch Go Builds + Google Cloud Build
View Dockerfile
FROM golang:alpine as builder
RUN apk update && apk add git && apk add tzdata
bamnet / .gitlab-ci.yml
Last active Jan 6, 2019
Multiarch Go Builds
View .gitlab-ci.yml
image: docker:latest
- docker:dind
- build
bamnet /
Last active Oct 20, 2018
Helper functions for use with the Google Maps JavaScript API to find points along a polyline.

Point Along Polyline

The percentAlongPath and distanceAlongPath functions below use the Geometry library of the Google Maps API to interpolate points a percentage or distance along a polyline. This can be useful to plot points along a polyline at regular intervals.

Note: The Geometry library must be loaded by appending &libraries=geometry to the <script> tag used to load the Google Maps API. For more information, check out the Library documentation.


View index.html
<style id="jsbin-css">
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
View places_result.json
"html_attributions" : [],
"results" : [
"formatted_address" : "101 Plaza Center, Secaucus, NJ 07094, United States",
"geometry" : {
"location" : {
"lat" : 40.79164149999999,
"lng" : -74.0568873
You can’t perform that action at this time.