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

As far as I know that openlayers can display our mouse coordinate position. However, I do not know how to display map center coordinate? Can anyone help me?

thanks for your helping guys!

share|improve this question

The easiest way would be to add an event to the map object so that on moveend some div (or something else) is updated. The map center itself can easily be retrieved from the map object with getCenter. For example:{
share|improve this answer
Thanks om henners, it is very helpful for me. But, that I want really is that the map center coordinate automatically appear in map as like as mouse coordinate position automatically appear in map (map.addControl(new OpenLayers.Control.MousePosition());) – rendi Oct 11 '12 at 5:54
use map.getCenter() inside the moveend event. – D_Guidi Oct 11 '12 at 6:48

You need to build a new Control, say OpenLayers.Control.MapCenter(). You can take OpenLayers.Control.MousePosition, rename it and change the registering of the events in the activate method. Remember also to change the unregistering in the deactivate method. Then you need to include js file with the definition of the new control and add it to you map: map.addControl(new OpenLayers.Control.MapCenter())

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.