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

sheetsee-maps

v1.0.0

Published

enables map creation functionality with sheetsee.js

Downloads

10

Readme

Standard - JavaScript Style Guide

sheetsee-maps

Sheetsee uses this module to handle maps in your projects. This module uses (and includes) Leaflet.js to make maps of your points, polygons, lines or multipolygons (all coordinate based). Details on what that actually looks like here. It uses (and includes) Mustache.js templates for marker popups.

You'll need to include Leaflet's map CSS in your HTML's head:

<head>
  <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
</head>

Maps: Polygons and Lines

Sheetsee-maps supports polygons and lines; so long as you have the correct coordinate structure in your cells. More details for coordinates of lines and polygons in geoJSON are here, but briefly:

Must use lowercase spreadsheet column headers: 'lat' and 'long'.

A linestring:

[-122.41722106933594, 37.7663045891584], [-122.40477561950684, 37.77695634643178]

A polygon:

[-122.41790771484375, 37.740381166384914], [-122.41790771484375, 37.74520008134973], [-122.40966796874999, 37.74520008134973],[-122.40966796874999, 37.740381166384914], [-122.41790771484375, 37.740381166384914]

A Multipolygon:

[[-122.431640625, 37.79106586542567], [-122.431640625, 37.797441398913286], [-122.42666244506835, 37.797441398913286],[-122.42666244506835, 37.79106586542567], [-122.431640625, 37.79106586542567]],
[[-122.43352890014648, 37.78197638783258], [-122.43352890014648, 37.789031004883654], [-122.42443084716797, 37.789031004883654], [-122.42443084716797, 37.78197638783258], [-122.43352890014648, 37.78197638783258]]

To Use

This module is used as a part of Sheetsee.js. You can download the full version or build your own with a command line tool.

You'll create a little bit of HTML and then some JavaScript in your HTML to use this. You can customize marker color, popup content and enable/disable clustering in your map.

Methods

Here are the functions you can use!

Sheetsee.createGeoJSON(data, optionsJSON)

  • data JSON array of data
  • optionsJSON array of strings, spreadsheet column title

If you'd like to just generate geoJSON from a spreadsheet you can use this method.

This takes in your spreadsheet data in JSON format (which you can get with Tabletop.js)and the parts of your data, optionsJSON, that you plan on including in your map's popups. These will be column headers in your spreadsheet in an array of strings.

If you're not going to have popups on your markers, don't worry about it then and just pass in your data (by default it will use all the row's information).

var optionsJSON = ['name', 'breed', 'cuddlability']
var geoJSON = Sheetsee.createGeoJSON(data, optionsJSON)

It will return an array in the special geoJSON format that map making things love.

Sheetsee.loadMap(options)

This method will generate a map for you on the page (it also generates the geoJSON for the map).

  • options object required
    • data your spreadsheet data array required
    • mapDiv the id of the div in your HTML to contain the map required
    • geoJSONincludes array of strings of column headers to include in popups
    • template HTML/Mustache template for popups
    • cluster a true/false boolean, do you want your markers clustered
    • hexcolor pick one color for your markers
var mapOptions = {
  data: data, // required
  mapDiv: 'map', //required
  geoJSONincludes: ['Name', 'Animal', 'Rating'], // optional
  template: '<p>{{Name}}—{{Animal}}—{{Rating}}</p>', // optional
  cluster: true, // optional
  hexcolor: '#e91e63' // optional
}
Sheetsee.loadMap(mapOptions)

Breaking Changes The latest version of Sheetsee replaces three methods ('loadMap', 'addTileLayer', 'addMarkerLayer') with one loadMap which takes in an object of map options.

Marker colors

If you create a column title hexcolor in your spreadsheet and fill each cell with hex color codes, those will be used to color your markers. If you define a color for hexcolor in the options you pass to your map it will override colors in the spreadsheet data.

View Demo Visit Site