Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.


Thanks to Nicklas' anwer to my previous question...
I was able to "combine my shapefile and CSV data have made a lot of progress on my project.

Now I want to display the attribute data in a popup when I either click or hover over a country.... I've done some goggling and looked at some examples but can't seem to make what I've seen work....
Can someone recommend a link or example I can look at?
I'm using mapserver and openlayers

Let me know if you'd like to see my script please let know

Thanks
Chris

share|improve this question

2 Answers 2

up vote 6 down vote accepted

I'd suggest checking this openlayers example: getfeatureinfo-control. It shows the feature info in a table on the page. Putting it into a popup should be easy changing some lines in the javascript.

In general openlayers.org/dev/examples/ is a good resource for openlayers code snippets.

share|improve this answer
    
Thanks for the link!! I followed one of the OL examples and got the pop-up box the shows up!! The problem I'm now having is the box wont close.... When each time I click on the x in upper right corner of a box, another pop-up box appears.... I can figure out whats happening!! Any ideas as to a sol'n would be gratefully appreciated!! Chris –  Chris Dec 1 '10 at 14:56

Is it possible that you are calling your popup creation function in the closeBoxCallback parameter? This is a snippet from some code I was working on:

      popup = new OpenLayers.Popup.FramedCloud(
             "popup",
             map.getLonLatFromViewPortPx(evt.xy),
             new OpenLayers.Size(300,150),
             "Updating<br/>information...",
             null,
             true,
             null
           );

The last null is in the place where you would put a callback function when the closeBox on the popup is clicked. In what I've displayed above, this is set to null and therefore, nothing is called and the popup doesn't reappear.

I saw in the "Open Popup on Layer.Vector" example in the OL Examples that there's a callback function here "onPopupClose". That unselects the feature which also I believe calls the onFeatureUnselect, which in turn destroys the popup. That is all setup in this line of that example:

selectControl = new OpenLayers.Control.SelectFeature(polygonLayer, {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});

So, it sounds like you need to either take out the closeBoxCallback in your popup creation (i.e. set it to null) or do something similar to this example that destroys the popup a bit later in the process.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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