This is a special case, I have many popups attached to objects and they work fine and I am having a problem in only one case.
All layers and popups are handled by select control's onFeatureSelect
, but this one is handled by layers featureSelected
event.
On opening popup it throws:
Uncaught TypeError: Cannot read property 'lat' of null.
Expanding error shows error on function OpenLayers.Bounds.OpenLayers.Class.determineQuadrant
but the popup opens.
On Clicking the close button, the click event is also fired and onPopupClose
function is also called ( I have checked it with monitor and monitorEvents in console) but the popup does not close. The popup in other layers is still function normally.
Here is the code:
select_Control = new OpenLayers.Control.SelectFeature([business, schools, healthfacilities, open_space], {
onSelect: onFeatureSelect,
onUnselect: onFeatureUnselect,
click: true
});
open_space.events.on({
"featureselected": function(e) {
var PopupPos1 = e.feature.geometry.getBounds().getCenterLonLat();
popup_content = '<div class="sites-embed-border-on sites-embed sites-embed-full-width" style="width:100%;"><div class="sites-embed-object-title" style="display:none;">sifal ground</div><div class="sites-embed-content sites-embed-type-spreadsheet"><iframe src="https://spreadsheets.google.com/spreadsheet/loadredirect?chrome=false&key=0AkXY0mfPYUxLdE9adGRXZFdlc1RxaHpIREtLbGhEZFE&output=html&pubredirect=true&widget=true" width="100%" height="600" title="sifal ground" frameborder="0" id="193883325"></iframe></div></div>';
var popup1 = new OpenLayers.Popup.FramedCloud("chicken",
PopupPos1,
null,
popup_content,
null, true, onPopupClose);
e.feature.popup = popup1;
map.addPopup(popup1);
popup1.setBackgroundColor('#FFBBBB');
popup1.updateSize();
popup1.draw();
}
})
function onPopupClose(e) {
select_Control.unselectAll();
}
function onFeatureSelect(feature) {
//debugger;
var PopupPos1 = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y)
popup_content = feature.attributes.name;
var popup1 = new OpenLayers.Popup.FramedCloud("chicken",
PopupPos1,
null,
popup_content,
null, true, onPopupClose);
feature.popup = popup1;
map.addPopup(popup1);
popup1.setBackgroundColor('#FFBBBB');
popup1.draw();
}
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
select_Control.unselectAll();
}