src/mmw/js/src/core/views.js
// Apply a mask over the entire map excluding bounds/shape specified.
Apply a mask over the entire map excluding bounds/shape specified.
Apply a mask over the entire map excluding bounds / shape specified .
function applyMask(featureGroup, shapeLayer) {
    var worldBounds = L.latLngBounds([-90, -360], [90, 360]),
        outerRing = getLatLngs(worldBounds),
        innerRings = getLatLngs(shapeLayer),
        polygonOptions = {
            stroke: true,
            color: '#fff',
            weight: 3.5,
            opacity: 1,
            fill: true,
            fillColor: '#000',
            fillOpacity: 0.5,
            clickable: false
        },
        latlngs = _.reduce(innerRings, function(acc, hole) {
            return acc.concat(hole);
        }, [outerRing]),
        maskLayer = L.polygon(latlngs, polygonOptions);
    featureGroup.clearLayers();
    featureGroup.addLayer(maskLayer);
}
function applyMask ( featureGroup , shapeLayer ) { var worldBounds = L . latLngBounds ( [ - 90 , - 360 ] , [ 90 , 360 ] ) , outerRing = getLatLngs ( worldBounds ) , innerRings = getLatLngs ( shapeLayer ) , polygonOptions = { stroke : true , color : '#fff' , weight : 3.5 , opacity : 1 , fill : true , fillColor : '#000' , fillOpacity : 0.5 , clickable : false } , latlngs = _ . reduce ( innerRings , function ( acc , hole ) { return acc . concat ( hole ) ; } , [ outerRing ] ) , maskLayer = L . polygon ( latlngs , polygonOptions ) ; featureGroup . clearLayers ( ) ; featureGroup . addLayer ( maskLayer ) ; }
Apply a mask over the entire map excluding bounds/shape specified.
Apply a mask over the entire map excluding bounds / shape specified .
// Should be a 2D array of latlngs where the first array contains // the exterior ring, and the following arrays contain the holes.