Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getWinkel3Projection = () => {
var lo = this.props.lo || 114.53; // x
var la = this.props.la || 35.21; // y
//console.log(geoProjection);
// https://www.bootcdn.cn/d3-geo-projection/readme/
// https://github.com/d3/d3-geo-projection/blob/master/src/winkel3.js
// https://bl.ocks.org/mbostock/3682676
//console.log("this.props.scale() is ",this.props.scale);
this.props.scale = this.props.scale || 0.6;
return geoProjection.geoWinkel3()
.center([0, la])
.rotate([-lo, 0])
.scale(this.getWidth() * this.props.scale)
// .translate([this.getWidth() / 2, this.getHeight() / 2]) // amormaid
.translate([window.innerWidth / 2, (window.innerHeight - 100) / 2])
.precision(1);
}
export default function (mapData, proj, scale, position, identifier, shapeKey) {
let projection = 'sphere';
switch (proj) {
case ('Mercator'): projection = d3.geoMercator(); break;
case ('Robinson'): projection = d3GeoProjection.geoRobinson(); break;
case ('Gall-Peter'): projection = d3GeoProjection.geoCylindricalEqualArea.parallel(45); break;
case ('Winkel-Tripel'): projection = d3GeoProjection.geoWinkel3(); break;
case ('Equirectangular'): projection = d3.geoEquirectangular(); break;
case ('Natural Earth1'): projection = d3.geoNaturalEarth1(); break;
case ('AlbersUSA'): projection = d3.geoAlbersUsa(); break;
default: projection = 'sphere'; break;
}
let features = topojson.feature(mapData, mapData.objects[shapeKey]).features;
if(!proj){
let countries = features.map((d, i) => d[identifier])
let obj1 = {}
for (let i = 0; i < countries.length; i++) {
obj1[countries[i]] = features[i]
}
let names1 = Object.keys(obj1);
let geoData1 = []
for (let i = 0; i < names1.length; i++) {
geoData1.push({
export default function (long, lat, proj, scale, position) {
let projection;
switch (proj) {
case ('Mercator'): projection = d3.geoMercator(); break;
case ('Robinson'): projection = d3GeoProjection.geoRobinson(); break;
case ('Gall-Peter'): projection = d3GeoProjection.geoCylindricalEqualArea.parallel(45); break;
case ('Winkel-Tripel'): projection = d3GeoProjection.geoWinkel3(); break;
case ('Equirectangular'): projection = d3.geoEquirectangular(); break;
case ('Natural Earth1'): projection = d3.geoNaturalEarth1(); break;
default: projection = d3GeoProjection.geoRobinson(); break;
}
let projection_scale = projection
.scale(scale)
.translate([position[0], position[1]]);
return (projection_scale([long, lat]));
}