How to use the d3-geo-projection.geoCylindricalEqualArea function in d3-geo-projection

To help you get started, we’ve selected a few d3-geo-projection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mustafasaifee42 / VR-Viz / src / Utils / GetMapShape.js View on Github external
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++) {
github mustafasaifee42 / VR-Viz / src / Utils / GetMapCoordinates.js View on Github external
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]));
}