Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
Access to an object of an object

I'm using Datamaps plugin and I'm trying to access to an object that is in another object.

Here I want to get all the values of data in options. Please see the console.log answer the screenshot below.

Here is the js:

var map = new Datamap({
  scope: "fra",
  element: document.getElementById("map-france"),
  responsive: true,
  fills: {
    defaultFill: "#EDE8D6",
    "1-50": color_dept[4],
    "51-100": "#EDE8D6",
    "101-150": "#E2DABF",
    "151-200": "#CEC191",
    "201-300": "#BCAE7C",
    "301-400": "#9D893E",
    "401-": "#827131",
  },
  data: {
    YV: {
      fillKey: "#EDE8D6",
    },
    AM: {
      fillKey: "51-100",
    },
  },
  geographyConfig: {
    popupTemplate: function (geo, data) {
      for (const val of uniqueValues) {
        if (geo.properties.name == val) {
          return [
            '<div class="hoverinfo"><strong>',
            val,
            "<br/>",
            dataValues.filter((v) => v == val).length,
            " parrainages",
            "</strong></div>",
          ].join("");
        }
      }
    },
    hideAntarctica: true,
    hideHawaiiAndAlaska: false,
    borderWidth: 1,
    borderOpacity: 1,
    borderColor: "#D2D3B5",
    popupOnHover: true, // True to show the popup while hovering
    highlightOnHover: true,
    highlightFillColor: "#1E2382",
    highlightBorderColor: "#FFFFFF",
    highlightBorderWidth: 1,
    highlightBorderOpacity: 1,
  },
  setProjection: function (element) {
    var projection = d3.geo
      .mercator()
      .center([2.454071, 46.279229])
      .rotate([0, 0])
      .scale(1700)
      .translate([350, 225]);
    var path = d3.geo.path().projection(projection);

    return {
      path: path,
      projection: projection,
    };
  },
});


Object.entries(map).map((item) => {
  console.log("item 1 : ", item);
});

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ex.

const mapExample = new Map()

mapExample.set("test", 
{"nestedObj":{"newObject":"new Obj value"}})

now, map over this would give you an array with the top level object "test"

to get the value of the nested value of "newObject":

Object.entries(mapExample.get("test")).map(i=> console.log(i[1].newObject))

or

Object.entries(mapExample.get("test")).map(i=> {
  let [key,value] = i
  console.log(key,value)
});

can copy and post this into chrome console and mess around with it, to see different outcomes.

but key take way is Object.entries return an array of your Object in ["key":"value"] order.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda