I want to show coordinate of every point in OSM. I am using OpenLayers 2. The below code is not working and does not show any error in the console. What is wrong with that code?

var popup = Ext.create('GeoExt.window.Popup', {
    map: mapPanel,
    width: 200

  // Add a pointerrest handler to the map component to render the popup.
  mapPanel.on('pointerrest', function(evt) {
    var coordinate = evt.coordinate;
    var lonlat = OpenLayers.Projection.transform(coordinate, 'EPSG:3857', 'EPSG:4326');
    var hdms = OpenLayers.coordinate.toStringHDMS(lonlat);
    popup.setHtml('<p>' + hdms + '</p>');

  // hide the popup once it isn't on the map any longer
  mapPanel.on('pointerrestout', popup.hide, popup);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.