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

@work-shop/map-module

v1.1.3

Published

Map module intended for integration in Work-Shop Wordpress environments.

Downloads

14

Readme

work-shop wordpress map module

This module was designed to streamline the development process of maps that get placed on Wordpress sites produced by Work-Shop.

Installation

Install via npm. npm install @work-shop/map-module.

Usage

The basic module usage looks like this:

<head>
  <!-- Basic map styles -->
  <link rel="stylesheet" href="map-style.css">

  <!-- Project specific map styles -->
  <link rel="stylesheet" href="map-usage.css">
</head>
<body>
  <!-- Options for the map -->
  <script>var mapOptions = { data: mapData };</script>

  <!-- Where should the map load? -->
  <div class="map-div" data-options="mapOptions"></div>

  <!-- Google Maps API -->
  <script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyDTkjwJK80N7YCWoKjhKz8c3J1tNEbJpRg" async defer></script>

  <!-- Bundle that includes map module & initialization calls. -->
  <script src="browserify'd-bundle.js"></script>
</body>
// browserify'd-bundle.js
var mapModule = require( '@work-shop/map-module' )
var maps = mapModule( { selector: '.map-div' } )

See the development directory for more usage examples.

Development

To develop the module: npm run dev. This will start a local development server, using files within the development directory as a place to initialize examples within. The source for the module itself lives in src.

  • src/initializer.js is an initialization layer that can be used to create any number of map instances using the { selector } option.
  • src/index.js is the map class that can be used to initialize a single map instance.
  • src/map-style.css is the style sheet that establishes basic necessary styles for the map.

Publish

To publish, the npm user must be part of the same team as the owner of the package. Then run:

npm publish --access public

HTML API

The HTML API entrypoint is src/initializer.js.

selector: The map DOM element should have a class or id that can be used to select it for initializing a map instance.

<!-- Basic example -->
<div class="map-div"></div>

data-options: Optionally, use this attribute to define the name of a global variable that carries options for initializing the map. Including map options, data to load, and render options.

<!-- Example with options. -->
<script>var mapOptions = { data: mapData };</script>
<div class="map-div" data-options="mapOptions"></div>

JS API

src/initializer.js ( default entry point )

Initializer( options ) => [ Maps ] returns an array of Map objects. Each Map object is initialized with the options passed into the function, and extended by any local options defined by the HTML API.

src/index.js

Map( options ) returns a Map object and is initialized with the options passed into the function. The Map object that can be used to set the data on the Map, render the data as features on the Map, and remove the features that have been previously rendered to the Map.

map.data( mapData? ) returns the current map data object when no arugments are passed in. Otherwise the mapData argument passed in is set as the maps current data. mapData is expected to be a single object with a marker key that defines options for rendering a Marker. Otherwise, it can be an array of objects with the same shape. When more map features are supported at this higher level, the mapData object can be expected to take on different shapes to support those other types of features.

map.render( renderOptions? ) returns the current map API object and will render the current mapData.

map.removeFeatures() returns nothing and does the opposite of the render function. It removes all features from the map.

src/marker.js

Marker( options ) returns a Marker object and is initialized with the options passed into the function. The Marker object can be used to render or remove the Marker from its map.

marker.render() returns the current marker API object and will render the marker on its map.

marker.remove() returns the current marker API object and will remove the marker from its map.

Marker options that include a popup key will have an OverlayPopup object created for the Marker.

src/overlay-popup.js

OverlayPopup( options ) returns an OverlayPopup object and is initialized with the options passed into the function. This object extends the google.maps.OverlayView.prototype.

Styling Tiles

src/tile-style.json is a default set of tile styles in the form of a JSON object, which is how Google Maps allows for customizing tile styles. These can be overriden using the styles key of the options object that is passed into the Map.

To create tile style JSON objects, use one of the following services that allow you to import and export these JSON tile style representations.