Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

329
Visualizações
Using PolyLabel with GeoJSON data and Google Maps

I am attempting to use the PolyLabel library with GeoJSON data and the Google Maps API to generate appropriately placed labels for irregular polygons. The documentation says that the library accepts polygon coordinates in GeoJSON-like format.

The problem is that I cannot figure out what data to pass from the Google Maps API data layer to PolyLabel to get the best fit label position.

polygons.forEach(function (feature) {
    var geo = feature.getGeometry();

    var position = polylabel(???, 1.0);

    var mapLabel = new MapLabel({
        position: position,
        text: feature.getProperty("LABEL"),
        fontSize: 25,
        fontColor: "red",
        map: map
    })

    currentLabels.push(mapLabel);
});

I have tried multiple variations on passing in the feature, the geometry, the raw coordinates, and constructing polygons from the coordinates.

It is also worth noting that the GeoJSON data contains a mixture of Polygons and MultiPolygons.

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

definitely difficult to see, but you can find it here. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/polylabel/index.d.ts

for each point in the polygon, you have [x, y]. Each polygon is then [[x,y]...], and polylabel takes array of polygons.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda