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

da-airmap-contextual-airspace-plugin

v1.3.2

Published

Mapbox GL JS plugin to view and interact with AirMap's Contextual Airspace Rules

Downloads

40

Readme

AirMap: The Airspace Platform for Developers

AirMap's Mapbox GL Contextual Airspace Plugin

Introduction

A control for mapbox-gl-js Mapbox GL JS plugin to view and interact with AirMap's Contextual Airspace Rules.

Requirements

To use the AirMap Contextual Airspace Plugin, you must register as a developer and obtain an API key from the AirMap Developer Portal. Once your application has been created, simply copy the provided config JSON to provide to the Contextual Airspace Plugin. You'll also need to register for a Mapbox Access Token.

Installation

From AirMap's CDN

<!-- Latest patch release -->
<script src="https://cdn.airmap.io/js/contextual-airspace/1.3.0/airmap.contextual-airspace-plugin.min.js"></script>

<!-- Latest minor release -->
<script src="https://cdn.airmap.io/js/contextual-airspace/v1.3/airmap.contextual-airspace-plugin.min.js"></script>

From npm

npm install airmap-contextual-airspace-plugin

After installing the airmap-contextual-airspace-plugin module via npm or bower, you'll need bundle it up along with its dependencies using a tool like webpack or browserify. If you don't have a build process in place for managing dependencies, it is recommended that you use the module via the CDN. See below for instructions on using with webpack and browserify. If you install with bower and intend to support ES5, you will also need to run your bundle through babel.

Usage

Here's an example of a minimal setup. See Documentation for more details.

<!doctype html>
<html>
    <head>
        <title>Mapbox-gl-js Ruleset Plugin</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <script src="https://cdn.airmap.io/js/contextual-airspace/v1.3/airmap.contextual-airspace-plugin.min.js" async=false defer=false></script>       
        <script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.js"></script>
        <link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.css" rel="stylesheet" />
        <style>
            body { margin: 0; padding: 0; }
            .map {
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                right: 0;
            }
        </style>
    </head>
    <body>
        <div id="map" class="map"></div>
        <script>
            const AIRMAP_API_KEY = localStorage.getItem('AIRMAP_API_KEY')
            const MAPBOX_ACCESS_TOKEN = localStorage.getItem('MAPBOX_ACCESS_TOKEN')
            if (AIRMAP_API_KEY && MAPBOX_ACCESS_TOKEN) {
                mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN
                const map = new mapboxgl.Map({
                    container: 'map',
                    style: 'mapbox://styles/mapbox/streets-v8',
                    center: [-118.496475, 34.024212],
                    zoom: 13
                })
                const config = {
                    "airmap": {
                        "api_key": AIRMAP_API_KEY
                    },
                    "auth0": {
                        "client_id": "",
                        "callback_url": ""
                    },
                    "mapbox": {
                        "access_token": MAPBOX_ACCESS_TOKEN
                    }
                }
                const options = {
                    preferredRulesets: [
                        'usa_part_107',
                        'deu_rules_waiver'
                    ],
                    overrideRulesets: [
                        // 'usa_part_107'
                    ],
                    enableRecommendedRulesets: true,
                    theme: 'light'
                    /* refer to the docs for a comprehensive list of options */
                }
                const plugin = new this.AirMap.ContextualAirspacePlugin(config, options);
                map.addControl(plugin, 'top-left')

                // Example for how ruleset changes are surfaced to the consuming application.
                plugin.on('jurisdictionChange', (data) => console.log('jurisdictionChange', data))
                plugin.on('airspaceLayerClick', (data) => console.log('airspaceLayerClick', data))
                
                // Example for how the consuming app can call the plugin for jurisdictions or selected rulesets.
                setTimeout(() => {
                    console.log({
                        jurisdictions: plugin.getJurisdictions(),
                        selectedRulelsets: plugin.getSelectedRulesets()
                    })
                }, 5000)
            } else {
                console.error(
                    'Missing AIRMAP_API_KEY or MAPBOX_ACCESS_TOKEN. ' +
                    'These are required for developing locally.\n\n' +
                    'Please save these values in localStorage by entering the following in your browser console:\n\n' +
                    'localStorage.setItem(\'AIRMAP_API_KEY\', \'<your_key>\');\n' +
                    'localStorage.setItem(\'MAPBOX_ACCESS_TOKEN\', \'<your_token>\');\n\n'
                );
            }
        </script>
    </body>
</html>

Or if using from NPM:

import ContextualAirspacePlugin from 'airmap-contextual-airspace-plugin'

const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v8',
    center: [-118.4932, 34.0135],
    zoom: 13
})
const config = {
    "airmap": {
        "api_key": AIRMAP_API_KEY
    },
    "auth0": {
        "client_id": "",
        "callback_url": ""
    },
    "mapbox": {
        "access_token": MAPBOX_ACCESS_TOKEN
    }
}
const options = {
    preferredRulesets: [
        'usa_part_107',
        'deu_rules_waiver'
    ],
    overrideRulesets: [
        // 'usa_part_107'
    ],
    enableRecommendedRulesets: true,
    theme: 'light'
}
const plugin = new ContextualAirspacePlugin(config, options);
map.addControl(plugin, 'top-left')

Prebuilt

If you are installing the Contextual Airspace Plugin with npm, a prebuilt package is also available in dist/airmap.contextualairspaceplugin.min.js. This will allow you to use the Contextual Airspace Plugin without changing your webpack/browserify configuration. However, using your bundler to package all dependencies is the preferred approach (webpack recommends against using prebuilt files).

Documentation

Generated API Documentation

Official AirMap Docs

Developing

Clone the repo and run npm install. Then run npm start and navigate to http://localhost:8080/ in your browser. The server will listen for changes and live reload as updates are made.

If this is your first time developing with the Contextual Airspace plugin, you'll need to store an AirMap API Key and Mapbox Access Token in your localStorage for use on the http://localhost:8080/ demo page:

localStorage.setItem('AIRMAP_API_KEY', '<your_key>');
localStorage.setItem('MAPBOX_ACCESS_TOKEN', '<your_token>');

Once this is done, you won't need to do it again unless you clear your browser's localStorage.

$ npm install
$ npm start
$ open http://localhost:8080/

License

See LICENSE for details.