NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I get this error when I call AddPopup():

Unable to get value of the property 'Left'; object is null or undefined

The same error occurs in both Chrome and IE. The map works fine when I comment out that line, and the markers work fine as well. Later, icon0 and lonLat0 will be several items in a loop, but I'll handle that. The end result should be a text box of some kind that would display on the marker.

The marker at lonLat0 displays, so it doesn't seem like a problem with the lonLat object.

Yes, I will end up displaying many markers with text on them all at once. I know, it seems silly, but that's the requirement.

Why does addPopup give me this error?

<div id='mapdiv'></div> <script src=''></script> 
  map = new OpenLayers.Map('mapdiv');
  map.addLayer(new OpenLayers.Layer.OSM());
  var lonLat = new OpenLayers.LonLat(-104.73,38.92).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject() );
  var markers = new OpenLayers.Layer.Markers( 'Markers' );
  markers.addMarker(new OpenLayers.Marker(lonLat));     
  function onPopupClose(evt) {selectControl.unselect(this.feature); }
  var icon0 = new OpenLayers.Icon("pinMS.png", new OpenLayers.Size(32,32), new OpenLayers.Pixel(-16,-32));  
  var lonLat0 = new OpenLayers.LonLat(-104.73,38.92).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject());  
  markers.addMarker(new OpenLayers.Marker(lonLat0, icon0.clone()));  
  map.addPopup(new OpenLayers.Popup.FramedCloud("featurePopup", lonLat0, new OpenLayers.Size(10, 10), "<h2>Title</h2>description", null, true, onPopupClose)); 
  map.setCenter (lonLat, 1);    

asked 02 Mar '12, 19:23

tsilb's gravatar image

accept rate: 0%

edited 02 Mar '12, 19:24

I had a play around in firefox with your code. For me it gives an error 'extent is null'

...which is easily fixed by swapping the last two lines around i.e. do map.setCenter before map.addPopup.

For me then it works apart from the size of the bubble popup is wrong and the close button doesn't work, so this would need more work.

You might find my little popups example here useful, except it's defining markers as vector features so it's a bit different.

permanent link

answered 04 Mar '12, 21:44

Harry%20Wood's gravatar image

Harry Wood
accept rate: 14%

That did it. Do you know of a way to make the popups smaller? My requirement is to have many of them with a small text blurb, visible all the time. Thanks.

(05 Mar '12, 17:45) tsilb

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 Mar '12, 19:23

question was seen: 6,466 times

last updated: 05 Mar '12, 17:45

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum