Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mapbox-gl-regex-query

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox-gl-regex-query

Query source data using regex

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Mapbox Regex Query

Query source data using a regex filter

This is an unofficial plugin, and is not affliated with Mapbox. 😇

🚧This is not using the public API and will likely break between versions🚧

  • Version 0.1.2 = tested with mapbox-gl-js v0.37.0
  • Version 0.2.0 = tested with mapbox-gl-js v0.43.0

This is my temporary workaround until regex is supported directly in mapbox-gl-js, I recommend helping with that directly if you can, see: https://github.com/mapbox/mapbox-gl-js/issues/4089

Installation

npm install mapbox-gl-regex-query

or to use directly in the browser download dist/mapbox-gl-regex-query.js from this repo

Usage

var RegexQuery = require('mapbox-gl-regex-search');

or in the browser

<script src="mapbox-gl-regex-query.js"></script>

The use by by calling querySourceFeatures

RegexQuery.querySourceFeatures(sourceID, filter, map);

Use ~= to active the regex filter. It also works in any and all filters.

Example:


var map = new mapboxgl.Map({
  /* ... */
});

var onSearchButtonClick = function(){
    var results = RegexQuery.querySourceFeatures('diners-drive-ins-and-dives',
    {
      sourceLayer: 'locations',
      filter: ['all',
        ['==', 'state', 'VA'],
        ['~=', 'name', '/.*burgers.*/g']
      ]
    },
    map);
}

Development

Build: npm run build-dev

License

BSD-3-Clause

Attributions

Portions adapted directly from the mapbox-gl-js, attributions are in the code

Keywords

FAQs

Package last updated on 04 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc