{"id":25636598,"url":"https://github.com/bbecquet/alt-route-labeller","last_synced_at":"2025-02-23T00:48:52.306Z","repository":{"id":57176875,"uuid":"325399505","full_name":"bbecquet/alt-route-labeller","owner":"bbecquet","description":"A library to compute the best position to put labels on multiple routes between two points","archived":false,"fork":false,"pushed_at":"2021-10-21T09:37:19.000Z","size":1112,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-15T19:46:25.456Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbecquet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-29T22:26:18.000Z","updated_at":"2023-01-13T23:10:22.000Z","dependencies_parsed_at":"2022-09-04T11:11:29.421Z","dependency_job_id":null,"html_url":"https://github.com/bbecquet/alt-route-labeller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbecquet%2Falt-route-labeller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbecquet%2Falt-route-labeller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbecquet%2Falt-route-labeller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbecquet%2Falt-route-labeller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbecquet","download_url":"https://codeload.github.com/bbecquet/alt-route-labeller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240254155,"owners_count":19772386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-23T00:48:51.463Z","updated_at":"2025-02-23T00:48:52.283Z","avatar_url":"https://github.com/bbecquet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alt-route-labeller\n\nA library to compute the best position to put labels on multiple routes between two points.\n\n![Example use-cases](examples.png)\n\n - [Showcase page](https://bbecquet.github.io/alt-route-labeller/examples/).\n - [In-depth explanation](https://bbecquet.net/articles/2020/12/labelling-alternative-routes/) as a blog article.\n\n## Installation\n\nDepending on your package manager:\n\n`npm install --save alt-route-labeller`\n\nor\n\n`yarn add alt-route-labeller`\n\n## Usage\n\nThe lib exposes the `getLabelPositions` function.\n\n### Parameters\n\n * **`routes`**: the multiple routes to apply the labelling to. Can be expressed as a GeoJSON [FeatureCollection](https://datatracker.ietf.org/doc/html/rfc7946#section-3.3), an array of [Feature](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) objects, or an array of [Geometry](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1) objects.\n\n### Return value\n\nAn array of label positions, one for each of the routes, in the same order as they where passed to the function.\n\nEach label position has the following properties:\n\n  * **`lngLat`**: the best position of the label on the route, put on a non-ambiguous section not shared with other routes (if one can be found, otherwise fallback on the route middle position).\n  * **`anchor`**: a hint value to minimize collisions if we want to display labels. Possible values: `top`|`bottom`|`left`|`right`. Inspired by the `anchor` property of [MapBox-GL-JS markers](https://docs.mapbox.com/mapbox-gl-js/api/markers/#marker).\n\n## Example\n\n```js\nimport { getLabelPositions } from 'alt-route-labeller';\n\nconst routes = getGeoJSONRoutesFromSomewhere();\nconst labels = getLabelPositions(routes);\nlabels.forEach(label =\u003e {\n  createMarkerOnMap(label.lngLat, { anchor: label.anchor });\n});\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbecquet%2Falt-route-labeller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbecquet%2Falt-route-labeller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbecquet%2Falt-route-labeller/lists"}