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

guidance-geojson

Package Overview
Dependencies
Maintainers
55
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guidance-geojson

guidance-geojson ---------------- Project for generating guidance-specific labelling/route styling data for GL from Mapbox Directions responses.

  • 0.3.0
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-37.04%
Maintainers
55
Weekly downloads
 
Created
Source

guidance-geojson

Project for generating guidance-specific labelling/route styling data for GL from Mapbox Directions responses.

var guidanceGeoJSON = require('guidance-geojson');

var geojson = guidanceGeoJSON(directionsResponse);
// console.log(geojson);

Styling Guidance GeoJSON

Guidance GeoJSON provides a FeatureCollection with the following feature types:

  • segments are LineString features that together make up the route to be traveled.
  • labels are Point features for maneuver points where the user needs to make a turn.
  • waypoints are Point features for starting, final, or intermediate destinations.

Each feature has the following properties exposed for styling in Mapbox Studio:

propertysegmentlabelwaypoint
typesegmentlabelwaypoint
bearingnull0-360null
modifiernullTBDnull
namenullName of next roadName of waypoint road
waypointnullnull`"first"

@TODO: provide example Guidance GeoJSON file for styling in studio as a static route.

Integrating Guidance GeoJSON dynamically with a Mapbox GL JS map

Once you have created your map style you can have it dynamically style a route. To do so, however, you will need to use the stylePrep() and styleRoute() methods to omit the layers in your style when loading your map and then apply those styles to your dynamic guidance GeoJSON once loaded:

var guidanceGeoJSON = require('guidance-geojson');
var mapboxgl = require('mapbox-gl');
var directionsResponse = require('./stored-directions-response.json');

var map = new mapboxgl.Map({
    container: 'map',
    // Defers showing all layers from `style` beginning with `route`
    style: guidanceGeoJSON.stylePrep(style, 'route')
});

map.on('style.load', function () {
    var route = guidanceGeoJSON(directionsResponse);
    // Restores style layers and adjusts dynamically to style `route` GeoJSON
    guidanceGeoJSON.styleRoute(mapboxgl, map, route);
});

FAQs

Package last updated on 16 May 2016

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