A maptalks Compass Control.
- Install with npm:
npm install maptalks.control.compass
. - Install with yarn:
yarn add maptalks.control.compass
. - Download from dist directory.
- Use unpkg CDN:
https://cdn.jsdelivr.net/npm/maptalks.control.compass/dist/maptalks.control.compass.min.js
andhttps://cdn.jsdelivr.net/npm/maptalks.control.compass/css/maptalks.control.compass.css
As a Maptalks.control, maptalks.control.compass
must be loaded after maptalks.js
in browsers. You can also use 'import { CompassControl } from "maptalks.control.compass"
and 'import "maptalks.control.compass/css/maptalks.control.compass.css"
when developing with webpack.
<!-- ... -->
<script src="https://cdn.jsdelivr.net/npm/maptalks.control.compass/dist/maptalks.control.compass.min.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/maptalks.control.compass/css/maptalks.control.compass.css"
/>
<!-- ... -->
// new Control: CompassControl, and add to map.
new maptalks.CompassControl({
position: 'top-right',
backgroundColor: '#00BCD4', // 'rgba(235, 235, 235, .65)'
transform: 'scale(1.2) translate(10%, 10%)',
resetViewTriggers: 'click dblclick', // ['dblclick contextmenu', {duration: 500}]
}).addTo(map)
// All options are optional.
new maptalks.CompassControl(options)
-
options [optional]
- position String - like other maptalks.Control.
- backgroundColor String - background-color of the compass.
- transform String - the compass dom's style: 'transform: %s'.
- resetViewTriggers String | Array - set
eventsOn
triggers on Compass to set map view to{bearing: 0, pitch: 0}
. IfArray
, the second value will be used as the animate options.
-
events
- add
- remove
- positionchange
- click
- dblclick
- contextmenu
We welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.
The only source file is index.js
.
It is written in ES6, transpiled by babel and tested with mocha and expect.js.
- Install dependencies
$ npm install
- Watch source changes and generate runnable bundle repeatedly
$ gulp watch
- Package and generate minified bundles to dist directory
$ gulp minify
- Lint
$ npm run lint