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

@mandrews6975/nav-urls

v1.1.1

Published

Generate navigation URLs for various map platforms such as Google Maps.

Downloads

11

Readme

Contributors Forks Stargazers Issues MIT License

About The Project

Nav-URLs generates navigation URLs for various map platforms. Currently, supported platforms include Google Maps, Apple Maps, and Bing Maps. Navigation routes can be generated by raw ordering or distance optimization. Generation of optimized navigation route URLs requires a MapQuest Developer API key. You can register and obtain a free MapQuest API key here.

Built With

Installation

Install via NPM:

npm install @mandrews6975/nav-urls

Function Reference

There are two preferred functions for generating navigation URLs (raw-ordered and optimized) and two deprecated functions that provide essentially the same functionality.

getRouteURL(locations, options)

Returns a raw-ordered navigation URL for the specified platform and locations.

  • Parameters
    • locations
      • Type: string[]
      • Description: locations/addresses written in formats standard map platforms understand (route is ordered from locations[0] to locations[n])
    • options
      • Type: {platform: 'google' | 'apple' | 'bing', travelmode: 'driving' | 'walking' | 'transit' | 'bicycling'}
        • Note: travelmode: 'bicycling' only supported by Google Maps
      • Description: object containing platform and travelmode
  • Returns:
    • Type: string
    • Description: raw-ordered navigation URL for the specified platform and locations

getOptimizedRouteURL(locations, key, options, callback)

Retrieves an optimized navigation URL for the specified platform and locations and passes said URL into its callback function.

  • Parameters
    • locations
      • Type: string[]
      • Description: array of locations/addresses written in formats standard map platforms understand (locations[0] is origin, locations[n] is destination, locations[1..n-1] are waypoints to be optimized)
    • key: string that is a MapQuest API key (register for a free key here)
    • options
      • Type: {platform: 'google' | 'bing', travelmode: 'driving' | 'walking' | 'transit' | 'bicycling'}
        • Note: travelmode: 'bicycling' only supported by Google Maps
      • Description: object containing platform and travelmode
    • callback
      • Type: (navURL: string) => any
      • Description: function that will be called after the URL is retrieved (takes the optimized navigation URL as a parameter)

[DEPRECATED] routeNav(locations, options)

Returns a raw-ordered navigation URL for the specified platform and locations.

  • Parameters
    • locations
      • Type: string[]
      • Description: locations/addresses written in formats standard map platforms understand (route is ordered from locations[0] to locations[n])
    • options
      • Type: {platform: 'google' | 'apple' | 'bing', travelmode: 'driving' | 'walking' | 'transit' | 'bicycling'}
        • Note: travelmode: 'bicycling' only supported by Google Maps
      • Description: object containing platform and travelmode
  • Returns:
    • Type: string
    • Description: raw-ordered navigation URL for the specified platform and locations

[DEPRECATED] routeNavOpt(locations, key, options)

Returns an optimized navigation URL (string) for the specified platform and locations.

  • Parameters
    • locations
      • Type: string[]
      • Description: array of locations/addresses written in formats standard map platforms understand (locations[0] is origin, locations[n] is destination, locations[1..n-1] are waypoints to be optimized)
    • key: string that is a MapQuest API key (register for a free key here)
    • options
      • Type: {platform: 'google' | 'bing', travelmode: 'driving' | 'walking' | 'transit' | 'bicycling'}
        • Note: travelmode: 'bicycling' only supported by Google Maps
      • Description: object containing platform and travelmode
  • Returns:
    • Type: string
    • Description: optimized navigation URL for the specified platform and locations

Usage

Example 1

Print raw-ordered Google Maps navigation URL to console:

const nav = require('@mandrews6975/nav-urls');

let locations = [
	'Denver',
	'New York City',
	'Des Moines, IA',
	"Devil's Tower",
	'Duck Key',
];
let options = {
	platform: 'google',
	travelmode: 'driving',
};

console.log(nav.getRouteURL(locations, options));

Result:

https://www.google.com/maps/dir/?api=1&origin=Denver&destination=Duck%20Key&travelmode=driving&waypoints=New%20York%20City%7CDes%20Moines%2C%20IA%7CDevil%27s%20Tower

Example 2

Print optimized Google Maps navigation URL to console:

let locations = [
	'Denver',
	'New York City',
	'Des Moines, IA',
	"Devil's Tower",
	'Duck Key',
];
let options = {
	platform: 'google',
	travelmode: 'driving',
};
let key = 'mapquest_api_key';

nav.getOptimizedRouteURL(locations, key, options, (navURL) =>
	console.log(navURL)
);

Result:

https://www.google.com/maps/dir/?api=1&origin=Denver&destination=Duck%20Key&travelmode=driving&waypoints=Devil%27s%20Tower%7CDes%20Moines%2C%20IA%7CNew%20York%20City

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Michael Andrews - GitHub: mandrews6975 - Email: [email protected]

Project Link: https://github.com/mandrews6975/Nav-URLs

Acknowledgements

Open Source Licenses