Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ig_markerfactory

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ig_markerfactory

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

  • 2.9.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Google Maps 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 and Fontello.

Build Status Code Climate Codacy Badge

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 be.

With MarkerFactory, you generate those icons on the fly.

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

Installation

Install it with jspm like so:

jspm install npm:ig_markerfactory

Or, if for some reason NPM is down:

jspm install github:huasofoundries/ig_markerfactory

If you don't use jspm, you can as well clone this repo and copy dist/markerfactory.js to your project.

Usage

This is a simple example using AMD loading:

	define(['huasofoundries/ig_markerfactory'], function(MarkerFactory) {

		var myIcon = MarkerFactory.autoIcon({
			label: 'f1b9',
			font: 'fontawesome-webfont',
			color: '#CC0000',
			fontsize: 20
			});

		console.log(myIcon);

	});

The 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

Example

run

npm install
jspm install
serve .

and open your browser at http://localhost:3000/example.html

FAQs

Package last updated on 06 Jul 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc