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

317
Views
OpenLayers - Heatmap | Override default overlap weight calculation

I am trying to implement an OpenLayers Heatmap to visualize some data on a map. My goal is to display heatmap points with given weights. Currently my poc code looks like this:

const features = [
  { lat: 46.934942, lon: 17.891804, id: 10, value: 6.5 },
  { lat: 46.93489, lon: 17.892713, id: 11, value: 5.2 },
  { lat: 46.934662, lon: 17.892331, id: 12, value: 5.9 },
].map((item) => {
  const feature = createFeature({
    lon: item.lon,
    lat: item.lat,
    id: `${item.id}`,
    customStyle: new olStyle.Style({
      image: new olStyle.Circle({
        radius: 5,
        fill: new olStyle.Fill({
          color: "#AB1F58",
        }),
      }),
    }),
  });

  feature.setProperties({ value: item.value });

  return feature;
});

const newLayer = new olLayer.Heatmap({
  source: new olSource.Vector({
    features,
  }),
  blur: 0,
  radius: 50,
  weight(feature) {
    return feature.getProperties().value / 10;
  },
});

map.addLayer(newLayer)

Example image

My problem is that OpenLayers sums the values when the features overlap but I would like the overlap area to have the average value.

Is this possible or should I look for another solution?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way that I can think of is by using a Cluster source. Write your own createCluster function to return a new feature with an average value and display this.

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!