Created
January 7, 2016 12:16
-
-
Save roblav96/019a4662bd5e14363571 to your computer and use it in GitHub Desktop.
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
self.doit = function ( pos, acc ) { | |
var points = { | |
"type": "FeatureCollection", | |
"features": [ { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ -71.16437494754791, | |
42.35219326967517 | |
] | |
} | |
}, { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [ -71.16197168827057, | |
42.352538171523115 | |
] | |
} | |
} ] | |
} | |
var polys = [] | |
var feats = points.features | |
var i, len = feats.length | |
for ( i = 0; i < len; i++ ) { | |
var polypoints = [] | |
var ii, len = 10 | |
for ( ii = 0; ii < len; ii++ ) { | |
var bearing = 360 * ( Number( '0.' + ii.toString() ) ) | |
var dest = turf.destination( feats[ i ], acc / 1000, bearing, 'kilometers' ).geometry.coordinates | |
console.log( 'dest >', dest ) | |
polypoints.push( dest ) | |
} | |
polypoints[ polypoints.length ] = polypoints[ 0 ] | |
polys[ i ] = turf.polygon( [ polypoints ] ) | |
} | |
var polyfeats = turf.featurecollection( polys ) | |
var source = new mapboxgl.GeoJSONSource( { | |
data: polyfeats | |
} ) | |
_$map.map.addSource( "polys", source ) | |
_$map.map.addLayer( { | |
'id': 'polys', | |
'type': 'fill', | |
'source': 'polys', | |
'paint': { | |
'fill-color': '#000', | |
'fill-opacity': 0.8 | |
} | |
} ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment