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

jquery-gmap

v2.1.1

Published

jQuery Wrapper for Google Maps API v3.

Downloads

108

Readme

jQuery.gmap

David Dev

Stop wasting your time typing Google Maps API code. Be more efficient.

To display a neat Google Map you have to write the same basic code every time. This plugin helps to create Google Maps with less code.

Dependencies

As this is a jQuery plugin it depends on the jQuery library and of course the Google Maps API v3. Thats it.

Usage

Include the Google Maps API v3 and jquery.gmap.min.js somewhere on your site, preferably before the closing body tag.

<script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=places" type="text/javascript"></script>
<script src="path/to/jquery.gmap.min.js"></script>

Create an element:

<div id="map"></div>

Initialize your map:

var $map = $('#map').gmap({
  lat: 52.5075419,
  lng: 13.4251364,
  options: {
    disableDefaultUI: true,
    zoom: 13
  }
});

$map.gmap('addMarker', {
  lat: 52.5075419,
  lng: 13.4251364,
  title: 'I am the title'
  infoWindow: {
    content: 'This is an info popup',
    opened: true
  }
});

The same map code without jquery.gmap would look like this:

var options = {
  disableDefaultUI: true,
  zoom: 13,
  center: new google.maps.LatLng(52.5075419, 13.4251364)
}
var map = new google.maps.Map(document.getElementById('map'), options);

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(52.5075419, 13.4251364),
  title: 'I am the title',
  map: map
});

var infowindow = new google.maps.InfoWindow({
  content: 'This is an info popup'
});

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map, marker);
});

infowindow.open(map, marker);

You can also specify options inline which will overwrite the default value and the value specified on initialization. You still have to initialize the map.

<div id="map" data-gmap-options='{"zoom":8}' data-gmap-lat="52.5075419" data-gmap-lng="13.4251364"></div>
$('#map').gmap();

Options

centerOnResize

Type: boolean
Default: true

Recenter the map to the current center if map gets resized.

singleInfoWindow

Type: boolean
Default: true

Only open one infoWindow at most. Automatically closes opened infoWindow if you click on a marker to open a different.

API

jQuery.gmap offers several methods which are wrappers for common Google Map API functions.

addMarker

Add a marker to a previously initialized map. You can attach an infoWindow with some content, set the marker icon and add a title. The optional infoWindow can be toggle via click on the marker.

$map.gmap('addMarker', {
  lat: 52.5075419,
  lng: 13.4251364,
  title: 'I\'m a title!',
  icon: '/path/to/icon.ext',
  infoWindow: { // optional
    content: 'Some content',
    opened: true // whether it should be opened on init
  }
});

setOptions

Set options after initialization. Extends current options, does not replace.

$('#map').gmap('setOptions', {
  scrollwheel: false,
  draggable: true
});

getMap

Not all features of Google Maps API v3 are covered by jquery.gmap. Therefore you can get the raw Map object and work with it as normal.

var $gmap = $('#map').gmap({
  ...
});

var map = $gmap.getMap();
// do whatever you like
var id = map.getDiv();

getMarker

Get all initialized marker objects.