JavaScript Development Space

Convert coordinates from EPSG-4326 to EPSG-3857

To convert coordinates from EPSG:4326 (WGS84 - latitude/longitude) to EPSG:3857 (Web Mercator projection) in JavaScript, you can use the following formula. This converts latitude and longitude into X and Y coordinates suitable for map display (such as Google Maps or OpenStreetMap).

Formula for Conversion:

Loading code editor...

Explanation:

  • RADIUS is the Earth's radius in meters for the Web Mercator projection.

  • Longitude is converted to the X coordinate by multiplying the longitude (in degrees) by the radius and converting it to radians.

  • Latitude is converted to the Y coordinate using the Mercator projection formula, which involves logarithms and trigonometric functions.

This conversion is necessary for displaying geographic coordinates on web-based mapping systems that use the EPSG:3857 projection.

JavaScript Development Space

JSDev Space – Your go-to hub for JavaScript development. Explore expert guides, best practices, and the latest trends in web development, React, Node.js, and more. Stay ahead with cutting-edge tutorials, tools, and insights for modern JS developers. 🚀

Join our growing community of developers! Follow us on social media for updates, coding tips, and exclusive content. Stay connected and level up your JavaScript skills with us! 🔥

© 2025 JavaScript Development Space - Master JS and NodeJS. All rights reserved.