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

easygooglemaps

v1.2.3

Published

Simple layer over Google Maps API for creating maps with markers and controlled balloons.

Downloads

36

Readme

npm version Dependency Status

Simple layer over Google Maps API to create expandable baloons(infoboxes) on the map. See example. We are tired of google maps syntax, infobox and whatever. Simple and straightforward syntax to do common job like this:

Module usage example

Installation

$ npm install --save easygooglemaps

Usage

Webpack

var EasyGoogleMaps = require('easygooglemaps');
// run module here

Old school files way (example.html):

<script type="text/javascript" src="easygooglemaps.js"></script>
<script type="text/javascript" src="RUN_MODULE_HERE.js"></script>

Running

var MyMap = new EasyGoogleMaps(_options_);
// options reference in next section

MyMap.init();

Parameters (options)

{
	// map options
	map: {
		APIKEY: 'YOUR_GOOGLEMAPS_API_KEY',
		container: '.js-map', // DOM element, where to put map
		options: {
			center: {lat: -34.097, lng: 150.644},
			zoom: 8
		}
	},

	// baloon specific options
	infobox: {
		class: 'awesome-infobox',
		template: '#infobox', // html template for baloon
		closeButton: '.js-infobox-close',
		onlyOneBox: true, // single baloon visible
		// baloon relative to marker position
		position: {
			x: "left",
			y: "center"	
		}
	},
	
	// Array of data (markers,baloons,infoboxes,whatever) to put on the map
	// Might be added at any time by .add method described below
	markers: {
		items: [
			{
				"content": {
					// this is {{=baloon.title}} in html template
					"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, consequatur."
				},
				"marker": {
					"position": {
						"lat": -34.397,
						"lng": 150.644
					},
					"icon": {
						"default": "img/markerDefault.png",
						"active": "img/markerActive.png",
						// for retina icon should be 40x60 pixels
						"size": {
							"x": 20,
							"y": 30
						},
						"centering": {
							"x": 10,
							"y": 30
						}
					}
				}
			}
		]
	}
}

And also HTML template (doT template engine) for infobox should be specified:

<script type="text/underscorejs" id="infobox">
	<div class="baloon">
		<button class="baloon__close js-infobox-close"></button>
		<div className="baloon__content">
			{{=baloon.title}}
		</div>
	</div>
</script>

Methods

Load (callback)

MyMap.onload(function() {
 	// show map with animation, once it is loaded
});

Add marker

// this method also accepts array of markers
MyMap.add({
	"content": {
		"title": "Lorem ipsum"
	},
	"marker": {
		"id": 5, // optional, only if you need to show-hide it later
		"position": {
			"lat": -34.397,
			"lng": 152.244
		},
		"icon": {
			"default": "img/markerDefault.png",
			"active": "img/markerActive.png", // optional
			"size": {
				"x": 41,
				"y": 58
			},
			"centering": {
				"x": 20,
				"y": 58
			}
		}
	}
});

Show-Hide by id

MyMap.show(2); // shows all markers (one or many) with id equal 2
MyMap.hide(2); // same, but hides

Google Map Object

Though our script wraps most of the use cases with map and infoboxes. You can still do whatever you want, because you have access to original Google Maps API:

MyMap.realmap; // returns Google Maps map object

Development

  • npm run build - Build task that generates both minified and non-minified scripts,
  • npm run watch - watch changes, build only minified version;

Authors:

Valentin ‘Whats0n’ Dorosh

Yuri akella Artiukh

License

MIT © Coderiver