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

ig_markerfactory

v2.13.0

Published

Uses canvas to generate google.maps.Marker Icons from graphic fonts (i.e. font-awesome) on the fly

Downloads

22

Readme

IG MarkerFactory

This is a zero dependencies library that uses a canvas element to generate valid google.maps.Marker Icons from graphic-fonts, such as Font-Awesome, Material-Icons or Fontello.

Travis Build Status Code Climate Codacy Badge npm Scrutinizer Build Scrutinizer Code Quality

Why?

Because some libraries, like google maps API, expect its Markers to have an valid google.maps.Icon to be shown on the map:

var mymarker = new google.maps.Marker({
	position: myMap.getCenter(),
	map: myMap
});

mymarker.setIcon({
	url: "/img/some_image.png",
	size: new google.maps.Size(54, 48),
	origin: new google.maps.Point(0, 0),
	anchor: new google.maps.Point(27, 24)
});

(Actually, it would be enough to set)

mymarker.setIcon("/img/some_image.png");

But still, you need an image. You'll need to host every icon and color combination thay might ever be.

With MarkerFactory, you generate those icons on the fly.

Example

See the example running at http://huasofoundries.github.io/ig_markerfactory/ and you'll be presented with three graphical fonts variations, both in their CSS render as well as their PNG rendering generated by IG_Markerfactory.

screenshot from 2016-07-06 12-00-51

Feel free to play with examples/example.js to see what happens when you try different colors, icons and scales.

Installation

Including it with a script tag

Include this package in your HTML file directly with a script tag using unpkg or jsdelivr

<script src="https://unpkg.com/ig_markerfactory/dist/markerfactory.min.js"></script>

or

<script src="https://cdn.jsdelivr.net/npm/ig_markerfactory/dist/markerfactory.min.js"></script>

Install with npm

Install it with npm like so:

npm install ig_markerfactory

Install with JSPM

Or include it in your JSPM/SystemJS project doing:

jspm install npm:ig_markerfactory

Usage

This is a simple example using AMD loading. It assumes you're using a font that's already present in the DOM.

AMD Style

define(["ig_markerfactory"], function(MarkerFactory) {
	var myIcon = MarkerFactory.autoIcon({
		label: "f1b9",
		font: "FontAwesome",
		color: "#CC0000",
		fontsize: 20
	});

	console.log(myIcon);
});

CommonJS Style

Require the library it with CommonJS format.

var MarkerFactory = require("ig_markerfactory");
var myIcon = MarkerFactory.autoIcon({
	label: "f1b9",
	font: "FontAwesome",
	color: "#CC0000",
	fontsize: 20
});

console.log(myIcon);

ES6 Style

If you're using an ES6 module bundler/transpiler (and you should!) import the ES6 version doing:

import { MarkerFactory } from "ig_markerfactory/dist/markerfactory.es6";

const myIcon = MarkerFactory.autoIcon({
	label: "f1b9",
	font: "FontAwesome",
	color: "#CC0000",
	fontsize: 20
});

console.log(myIcon);

You will see that myIcon object is a valid google.maps.Icon object, but of course you might want the image for other purposes so you can just use myIcon.url which is a data URI