{"id":23974308,"url":"https://github.com/qazsato/maplibre-gl-compass","last_synced_at":"2025-04-13T22:24:50.286Z","repository":{"id":265466298,"uuid":"895288331","full_name":"qazsato/maplibre-gl-compass","owner":"qazsato","description":"A heading-up compass for MapLibre GL JS 🧭","archived":false,"fork":false,"pushed_at":"2024-12-07T01:10:23.000Z","size":985,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T12:46:55.347Z","etag":null,"topics":["compass","maplibre-gl-js"],"latest_commit_sha":null,"homepage":"https://qazsato.github.io/maplibre-gl-compass/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qazsato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-27T23:24:35.000Z","updated_at":"2025-03-17T11:39:14.000Z","dependencies_parsed_at":"2024-11-29T14:26:29.484Z","dependency_job_id":"94c066e4-a443-43a1-9d77-34b77ca6a1c7","html_url":"https://github.com/qazsato/maplibre-gl-compass","commit_stats":null,"previous_names":["qazsato/maplibre-gl-compass"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qazsato%2Fmaplibre-gl-compass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qazsato%2Fmaplibre-gl-compass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qazsato%2Fmaplibre-gl-compass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qazsato%2Fmaplibre-gl-compass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qazsato","download_url":"https://codeload.github.com/qazsato/maplibre-gl-compass/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790017,"owners_count":21161931,"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":["compass","maplibre-gl-js"],"created_at":"2025-01-07T05:35:10.118Z","updated_at":"2025-04-13T22:24:50.112Z","avatar_url":"https://github.com/qazsato.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# maplibre-gl-compass\n\n[![npm version](https://badge.fury.io/js/maplibre-gl-compass.svg)](https://badge.fury.io/js/maplibre-gl-compass)\n[![npm downloads](https://img.shields.io/npm/dm/maplibre-gl-compass.svg)](https://badge.fury.io/js/maplibre-gl-compass)\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\nA **heading-up** compass for MapLibre GL JS 🧭\n\nThis plugin rotates the map based on the values from the [Device orientation events](https://developer.mozilla.org/en-US/docs/Web/API/Device_orientation_events).  \nTherefore, it can only be used on devices equipped with an orientation sensor, such as mobile devices.\n\nDemo page is [here](https://qazsato.github.io/maplibre-gl-compass).\n\n## Installation\n\n```sh\nnpm install maplibre-gl-compass\n```\n\n## Usage\n\n### Basic usage\n\n```js\nimport { Map } from 'maplibre-gl'\nimport 'maplibre-gl/dist/maplibre-gl.css'\nimport { CompassControl } from 'maplibre-gl-compass'\nimport 'maplibre-gl-compass/style.css'\n\nconst map = new Map({/* YOUR_MAP_OPTION */})\n\nmap.addControl(new CompassControl())\n```\n\n### Advanced usage\n\n```js\nimport { Map } from 'maplibre-gl'\nimport 'maplibre-gl/dist/maplibre-gl.css'\nimport { CompassControl } from 'maplibre-gl-compass'\nimport type { CompassEvent, CompassError } from 'maplibre-gl-compass'\nimport 'maplibre-gl-compass/style.css'\n\nconst map = new Map({/* YOUR_MAP_OPTION */})\n\nconst compass = new CompassControl({\n  debug: true,    // Show debug view. Default is false.\n  visible: true,  // Show compass button. Default is true.\n  timeout: 10000, // The maximum time to wait for a DeviceOrientationEvent. Default is 3000 [ms].\n})\n\ncompass.on('turnon', () =\u003e {\n  // Set pitch when compass is turned on.\n  map.setPitch(45)\n})\n\ncompass.on('turnoff', () =\u003e {\n  // Restore pitch and north up when compass is turned off\n  map.setPitch(0)\n  map.setBearing(0)\n})\n\ncompass.on('compass', (event: CompassEvent) =\u003e {\n  // Your custom logic is here!\n})\n\ncompass.on('error', (event: CompassError) =\u003e {\n  // Your custom logic is here!\n})\n\nmap.addControl(compass)\n```\n\n## Options\n\n| name    | default | description                                                |\n| ------- | ------- | ---------------------------------------------------------- |\n| debug   | false   | Show debug view.                                           |\n| visible | true    | Show compass button.                                       |\n| timeout | 3000    | The maximum time[ms] to wait for a DeviceOrientationEvent. |\n\n## Events\n\n| name    | description                                                                                                                                                                                                                                                 |\n| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| turnon  | Fired when the compass is turned on.                                                                                                                                                                                                                        |\n| turnoff | Fired when the compass is turned off.                                                                                                                                                                                                                       |\n| error   | Fired when the compass cannot be accessed due to permission denied or a timeout.                                                                                                                                                                            |\n| compass | Fired when the device orientation changes. \u003cbr\u003e A `heading` number represents the difference between the motion of the device around the z axis of the world system and the direction of the north, expressed in degrees with values ranging from 0 to 360. |\n\n## Reference\n\n- https://developer.apple.com/documentation/webkitjs/deviceorientationevent\n- https://developer.mozilla.org/en-US/docs/Web/API/Window/deviceorientationabsolute_event\n\n## License\n\nThis project is licensed under the terms of the [MIT license](https://github.com/qazsato/maplibre-gl-compass/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqazsato%2Fmaplibre-gl-compass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqazsato%2Fmaplibre-gl-compass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqazsato%2Fmaplibre-gl-compass/lists"}