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 am very new to openlayers. I have done showing map and whenever we click on the map it is showing marker. But i need to open the popup when i click on the marker.

The following code has some problem. When i click on marker popup is displaying but at the corner it is displaying. I want to display the popup on the marker it self

  <div id="mapdiv"></div>
  <script src=""></script>
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());

    var lonLat = new OpenLayers.LonLat( -0.1279688 ,51.5077286 )
            new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
            map.getProjectionObject() // to Spherical Mercator Projection

    var zoom=16;
    var markers = new OpenLayers.Layer.Markers( "Markers" );
    map.addLayer(markers);"click", map , function(e){
   var opx = map.getLonLatFromPixel(e.xy) ;
   var marker = new OpenLayers.Marker(opx);
   markers.addMarker(marker);"click", marker, function(e){
   popup = new OpenLayers.Popup("chicken",
                   new OpenLayers.Size(200,200),
                   "example popup",


    map.setCenter (lonLat, zoom);
share|improve this question
up vote 2 down vote accepted

Try this:

  popup = new OpenLayers.Popup.FramedCloud("chicken",
                         new OpenLayers.Size(200, 200),
                         "example popup",
                         null, true);

enter image description here

share|improve this answer
thank you very much... – Ramesh Kotha Mar 28 '12 at 16:25

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.