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

locusmaps-sdk

v1.1.2

Published

This project contains a small script which can be used to initialize and control a LocusMaps instance. It is sometimes referred to as the "SDK Client".

Downloads

1,254

Readme

locusmaps-sdk

This project contains a small script which can be used to initialize and control a LocusMaps instance. It is sometimes referred to as the "SDK Client".

The emphasis here is that this script remains extremely small (about 2k gzipped) - and does not change very often. Also, the resources required to display a map are not downloaded until and unless you request a map to be shown. So if there are conditions in which a map may not shown, there is very little penalty to have loaded or included this script into your web page.

If you do initialize a map on the page, a resource bundle is downloaded which contains all the map rendering and controlling code. This resource bundle is loaded from LocusLabs servers - it is referred to as the "SDK Server Bundle".

Usage

There are several ways to get the SDK client incorporated into your web site or web application. Using a package manager, such as npm or yarn - or by simply adding a script tag to your web page.

Installation via npm / yarn

The SDK client is registered with npmjs as locusmaps-sdk, so you may install via:

npm install locusmaps-sdk
# or
yarn add locusmaps-sdk

You can then use in either ES6 module style (import) or CJS module style (require).

ES6 Module Style

import LMInit from 'locusmaps-sdk'

CJS Module Style

const LMInit = require('locusmaps-sdk')

Using LMInit

Then, when you are ready to initialize the map with a given config:

LMInit.newMap('#map', config)
  .then(mapReady)
  .catch(e => console.error('Error initializing map: ', e))

function mapReady(map) {
	// Your map is ready to use here!
}

Using Directly in your HTML

If you don't use a bundler, we have also made the script available via UMD (Universal Module Definition) and ES6 bundles to be injected directly to inject into your webpage.

UMD

The UMD bundle is compatible with Require.js or as a standalone <script> insertion:

Require.js (also known as AMD)

To use with RequireJS, simply refer to the URL of the UMD in your require call:

require(['https://maps.locuslabs.com/sdk/LocusMapsSDK-umd.js'], LMInit => {
	const config = { /* ... */ }
	LMInit.newMap('#map', config)
	  .then(mapReady)
	  .catch(e => console.error('Error initializing map: ', e))
 })

function mapReady(map) {
	// Your map is ready to use here!
}
Directly on page (ES5)

This approach simply injects the UMD script directly on the page, which exposes the LMInit global variable:

<head>
	<script src="https://maps.locuslabs.com/sdk/LocusMapsSDK-umd.js"></script>
	<script>
		const config = { /* ... */ }
		LMInit.newMap('#map', config)
			.then(mapReady)
			.catch(e => console.error('Error initializing map: ', e))

		function mapReady(map) {
			// Your map is ready to use here!
		}
	</script>
</head>

ES6 modules

If you are embracing the most recent module format, the ES6 Module format, then you can use the ES6 module build directly as well:

	<head>
		<script type="module">

			import LMInit from 'https://maps.locuslabs.com/sdk/LocusMapsSDK.js'

			const config = { /* ... */ }

			LMInit.setLogging(true)

			function go() {
			LMInit.newMap('#map', config)
				.then(start)
				.catch(e => console.error('Error initializing map: ', e))
			}

			function start(map) {
				// Your map is ready to use here!
			}

		</script>
	</head>