Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!