I get this error when I call AddPopup():

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

http://www.openlayers.org/api/OpenLayers.js

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?

<html><body>   
<div id='mapdiv'></div> <script src='http://www.openlayers.org/api/OpenLayers.js'></script> 
<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' );
  map.addLayer(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);    
</script></body></html>

asked 02 Mar '12, 19:23

tsilb's gravatar image

tsilb
16112
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
9.3k2486126
accept rate: 13%

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
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×532
×112
×17

question asked: 02 Mar '12, 19:23

question was seen: 5,024 times

last updated: 05 Mar '12, 17:45

powered by OSQA