Skip to content

Commit

Permalink
fix(Leaflet#3) Add dash array option
Browse files Browse the repository at this point in the history
  • Loading branch information
James Bosworth committed Jul 3, 2018
1 parent 472b54a commit 26835e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ Check out the [demo](https://cloudybay.github.io/leaflet.latlng-graticule/exampl
### Usage example

```javascript
L.latlngGraticule({
showLabel: true,
zoomInterval: [
{start: 2, end: 3, interval: 30},
{start: 4, end: 4, interval: 10},
{start: 5, end: 7, interval: 5},
{start: 8, end: 10, interval: 1}
]
}).addTo(map);
L.latlngGraticule({
showLabel: true,
dashArray: [5, 5],
zoomInterval: [
{start: 2, end: 3, interval: 30},
{start: 4, end: 4, interval: 10},
{start: 5, end: 7, interval: 5},
{start: 8, end: 10, interval: 1}
]
}).addTo(map);
```


Expand All @@ -30,6 +31,7 @@ Check out the [demo](https://cloudybay.github.io/leaflet.latlng-graticule/exampl
- **color**: The color of the graticule lines. Default `#aaa`
- **font**: Font Style for the tick label. Default `12px Verdana`
- **fontColor**: Color of the tick label. Default `#aaa`
- **dashArray**: Used to achieve dashed lines. Default `[0,0]`
- **zoomInterval**: Use different intervals in different zoom levels. You can set for both latitude and longitude lines as the example, or set different intervals for latitude and longitude like below:
```javascript
zoomInterval: {
Expand Down
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

L.latlngGraticule({
showLabel: true,
dashArray: [5, 5],
zoomInterval: [
{start: 2, end: 3, interval: 30},
{start: 4, end: 4, interval: 10},
Expand Down
2 changes: 2 additions & 0 deletions leaflet.latlng-graticule.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
weight: 0.8,
color: '#aaa',
font: '12px Verdana',
dashArray: [0,0],
lngLineCurved: 0,
latLineCurved: 0,
zoomInterval: [
Expand Down Expand Up @@ -298,6 +299,7 @@
ctx.lineWidth = this.options.weight;
ctx.strokeStyle = this.options.color;
ctx.fillStyle = this.options.fontColor;
ctx.setLineDash(this.options.dashArray);

if (this.options.font) {
ctx.font = this.options.font;
Expand Down

0 comments on commit 26835e0

Please sign in to comment.