Skip to content

Commit

Permalink
adding svg layer...
Browse files Browse the repository at this point in the history
ref #5587
  • Loading branch information
maxgrossman committed Dec 18, 2018
1 parent 029f702 commit 02261c9
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions modules/svg/geolocate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

export function svgGeolocate(projection, context, dispatch) {
var throttledRedraw = _throttle(function () { dispatch.call('change'); }, 1000);
var minZoom = 12;
var layer = d3_select(null);
var _mapillary;


function init() {
if (svgGeolocate.initialized) return; // run once
svgGeolocate.enabled = false;
svgGeolocate.initialized = true;
}

function showLayer() {
layer.attr('display', 'block');
layerOn();
}


function hideLayer() {
throttledRedraw.cancel();
layer
.transition()
.duration(250)
.style('opacity', 0)
.on('end', function() {});
}

function layerOn() {
layer
.style('opacity', 0)
.transition()
.duration(250)
.style('opacity', 1)
.on('end', function () { dispatch.call('change'); });

}

function layerOff() {
// layer.selectAll('.viewfield-group').remove();
layer.style('display', 'none');
}

function update(location) {

var groups = layer.selectAll('.markers').selectAll('.viewfield-group')
.data([location]);

}

function drawLocation(selection) {
var enabled = svgGeolocate.enabled;

layer = selection.selectAll('.layer-mapillary-signs')
.data([]);

layer.exit()
.remove();

layer = layer.enter()
.append('g')
.attr('class', 'layer-geolocate-point')
.style('display', enabled ? 'block' : 'none')
.merge(layer);

if (enabled) {
layerOn();
update();
} else {
layerOff();
}
}

drawLocation.enabled = function(_) {
if (!arguments.length) return svgGeolocate.enabled;
svgGeolocate.enabled = _;
if (svgGeolocate.enabled) {
showLayer();
} else {
hideLayer();
}
dispatch.call('change');
return this;
};



init();
return drawLocation;
}

0 comments on commit 02261c9

Please sign in to comment.