1

I am trying to update some popups in my map but I am not able to do that.

Firstly I create some markers, and with the next code, I create a popup associated to them. One popup for each marker:

 popFeature = new OpenLayers.Feature(markers, location); 
                         popFeature.closeBox = true;
                         popFeature.popupClass =     OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
                                 'autoSize': true
                         });
                         popFeature.data.popupContentHTML = "hello";                         
popFeature.data.overflow = (false) ? "auto" : "hidden";     
                         var markerClick = function (evt) {
                                if (this.popup == null) {
                                    this.popup = this.createPopup(this.closeBox);
                                    map.addPopup(this.popup);
                                    this.popup.show();
                                } else {
                                    this.popup.toggle();
                                }
                                currentPopup = this.popup;
                                OpenLayers.Event.stop(evt);
                         };
                         mark.events.register("mousedown",     popFeature, markerClick);

After that, I add the new marker to my marker layer.

Everything is fine until here, but, I want to update the popupcontentHTML some time later and I don't know how I can access to that value.

I read OL API but I don't understand how to get it. I am lost about features, events, extensions...

I want to know if I can access to that property and write other word.

1 Answer 1

5

I answer myself, maybe it helps other people in future:

for(i = 0; i < map.popups.length; i++){
if(map.popups[i].lonlat.lon == marker.lonlat.lon){
map.popups[i].setContentHTML("new content");
}
}

Content will be refreshed at the moment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.