Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get the coordinates of the click when the user clicks on any place on the base map. I have checked the answer to similar problem here: How do I get the coordinates of a click on vector feature/layer in OpenLayers?

But, I need the coordinates transformed to the projection system used by my map: that is EPSG:900913, Spherical Mercator Projection and passed to a html textbox.

How can I do that?

share|improve this question
up vote 2 down vote accepted

You should use the OpenLayers.LonLat.transform() function.

If you want to transform between EPSG 4326 & EPSG:900913, Openlayers can do it for you.

If you want to transform between some other projections, then you will have to use the Proj4js library.

Include in your page:

<script src=""></script>

Then in your javascript

var lonlat = yourpoint.clone();
lonlat.transform(map.projection, <target projection>);

Note that transform() changes the actual object, so if you need the orignal object for something, remember to clone it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.