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

138
Views
How can I convert lng and lat from OpenLayers to mapbox?

OpenLayers uses an array like this: [15711464.77174924, 1340284.424706252] to handle center's coordinates, but for mapbox-gl I should set a value between -90 to 90 and I get this error:

Error: Invalid LngLat latitude value: must be between -90 and 90

So, is there any way to convert a coordinates like: 15711464.77174924 to between -90 to 90?

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

0

Spherical mercator coordinates assume the world is a sphere of radius 6378137 meters. To convert to degrees (based on the OpenLayers source code https://github.com/openlayers/openlayers/blob/main/src/ol/proj/epsg3857.js#L132-L134) the function would be

function toLonLat(input) {
    const RADIUS = 6378137;
    const HALF_SIZE = Math.PI * RADIUS;

    const lon = (180 * input[0]) / HALF_SIZE;
    const lat =
      (360 * Math.atan(Math.exp(input[1] / RADIUS))) / Math.PI - 90;

    return [lon, lat];
}
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!