
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@getcircuit/marker-generator
Advanced tools
The Google Maps JS SDK accepts both SVGs and rasterized images as a way to display a marker on a map. While SVGs are extremely versatile, they can be quite CPU intensive if one has more than a few dozens of markers appearing at the same time. `@getcircuit
The Google Maps JS SDK accepts both SVGs and rasterized images as a way to display a marker on a map. While SVGs are extremely versatile, they can be quite CPU intensive if one has more than a few dozens of markers appearing at the same time. @getcircuit/marker-generator is Circuit's solution to generate markers with dynamic colors, text, and symbols, while keeping the performance of rasterized images.
The @getcircuit/marker-generator exports a getMarker method. It receives a MarkerDescription and returns a promise that resolves to the GeneratedMarker.
getMarker(markerDescription: MarkerDescription): Promise<GeneratedMarker>
A MarkerDescription object describes how the marker should look like:
type MarkerDescription = {
/**
* Defines the template to use to generate the marker.
* @default 1
* */
width: MarkerWidth
/**
* Scales the marker image proportionally.
* @default 1
* */
scaleFactor: number
/**
* Defines the font to use to generate the marker.
* https://developer.mozilla.org/en-US/docs/Web/CSS/font
* @default "400 14px 'TT Commons', sans-serif"
* */
font?: string
/**
* Defines the marker text
* @default undefined
* */
text?: string
/**
* Defines the marker symbol.
* @default undefined
* */
symbol?: MarkerSymbol
/**
* Background color
* @default '#000'
* */
backgroundColor: string
/**
* Outline color
* @default '#000'
* */
outlineColor: string
/**
* Symbol color
* @default '#000'
* */
symbolColor?: string
/**
* Text color
* @default '#000'
* */
textColor?: string
}
A GeneratedMarker object consists of everything that one may need to use the marker image in a Google Maps map:
type GeneratedMarker = {
/** Marker image URL */
src: string
/** Marker image size in pixels */
size: { width: number; height: number }
/** Anchor point for the marker */
anchor: { x: number; y: number }
}
import { getMarker } from '@getcircuit/marker-generator'
getMarker({
width: 1,
symbol: 'unoptimized',
backgroundColor: '#fff',
outlineColor: '#000',
symbolColor: '#000',
}).then(({ src, size, anchor }) => {
// Use src, size, anchor to create a google.maps.Icon
})
Generates the following marker image:
getMarker method, it first checks if a marker was already generated with the same description.width, backgroundColor and outlineColor is created and cached. Let's call this the templateImage.symbol was specified, the symbol image for the specified symbol and symbolColor is created and cached. Let's call this the symbolImage.templateImage.templateImage on the canvas.text and/or symbolImage on the canvas.
text and/or symbolImage as the markerContent.markerContent by adding their widths and a small padding between them.markerContent:
(template width - content width) / 2.(template width - content width) / 2 + content width.right position - symbol width.left position, using the specified font and textColor.Blob. The package detects if the browser support webp. If yes, the blob is a webp, png otherwise.Blob image via createObjectURL.url, anchor and size.FAQs
The Google Maps JS SDK accepts both SVGs and rasterized images as a way to display a marker on a map. While SVGs are extremely versatile, they can be quite CPU intensive if one has more than a few dozens of markers appearing at the same time. `@getcircuit
The npm package @getcircuit/marker-generator receives a total of 0 weekly downloads. As such, @getcircuit/marker-generator popularity was classified as not popular.
We found that @getcircuit/marker-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.