-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat osm layer like other vector layers and give it a toggle
(closes #2904)
- Loading branch information
Showing
5 changed files
with
151 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,61 @@ | ||
export function svgOsm() { | ||
return function drawOsm(selection) { | ||
var layers = selection.selectAll('.layer-osm') | ||
.data(['areas', 'lines', 'hit', 'halo', 'label']); | ||
export function svgOsm(projection, context, dispatch) { | ||
var enabled = true; | ||
|
||
layers.enter() | ||
|
||
function drawOsm(selection) { | ||
selection.selectAll('.layer-osm') | ||
.data(['areas', 'lines', 'hit', 'halo', 'label']) | ||
.enter() | ||
.append('g') | ||
.attr('class', function(d) { return 'layer-osm layer-' + d; }); | ||
} | ||
|
||
|
||
function showLayer() { | ||
var layer = context.surface().selectAll('.data-layer-osm'); | ||
layer.interrupt(); | ||
|
||
layer | ||
.classed('disabled', false) | ||
.style('opacity', 0) | ||
.transition() | ||
.duration(250) | ||
.style('opacity', 1) | ||
.on('end interrupt', function () { | ||
dispatch.call('change'); | ||
}); | ||
} | ||
|
||
|
||
function hideLayer() { | ||
var layer = context.surface().selectAll('.data-layer-osm'); | ||
layer.interrupt(); | ||
|
||
layer | ||
.transition() | ||
.duration(250) | ||
.style('opacity', 0) | ||
.on('end interrupt', function () { | ||
layer.classed('disabled', true); | ||
dispatch.call('change'); | ||
}); | ||
} | ||
|
||
|
||
drawOsm.enabled = function(_) { | ||
if (!arguments.length) return enabled; | ||
enabled = _; | ||
|
||
if (enabled) { | ||
showLayer(); | ||
} else { | ||
hideLayer(); | ||
} | ||
|
||
dispatch.call('change'); | ||
return this; | ||
}; | ||
|
||
|
||
return drawOsm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters