Problem creating Popup content for Openlayers

I have a map created using OpenLayers and now i am working to get a popup configured correctly.  I have a feature attribute which contains a file name for a PDF.  When the feature is clicked I would like to be able to create a link to the filename but I am having problem getting the link to work.  Below is the content for the popup but it does not create the link:

"Owner: " + feature.attributes.OWNER + " <br> " + "<a href=" + feature.attributes.AB_PDF + ">"
GreyHippoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
What errors are you getting in the console?  You will need to post a link so we can see what you are doing in context.

Cd&
0
GreyHippoAuthor Commented:
I am reading all my layers into the map via a remote JSON file and within the JSON file there are information for each layer such name, geojson url, stylemap, and information for a popup.

JSON file:

{
"layers": [
{ "title":"FTMA San Pipe" , "url":"./ftma_sanpipe_3857.geojson" , "style": "layer.styleMap = sanpipe_stylemap;", "info" : "\"Owner: \" + feature.attributes.OWNER + \" <br> \" + \"<a href=\" + feature.attributes.AB_PDF + \">\""},
{ "title":"FTMA San MH" , "url":"./ftma_sanmh_3857.geojson" , "style" : "layer.styleMap = manhole_stylemap;", "info" : "\"Mh ID: \" + feature.attributes.STRUCT_ID"}
]
}

Open in new window


Below is the code for the popup:
function onFeatureSelect(evt) {
                feature = evt.feature;
				//console.log(feature);
				//console.log(feature.layer.name);
				console.log(feature.layer.popup_info);
                popup = new OpenLayers.Popup.FramedCloud("featurePopup",
                                         feature.geometry.getBounds().getCenterLonLat(),
                                         new OpenLayers.Size(200,200),
                                         eval (feature.layer.popup_info),
                                         null, true, onPopupClose);
                feature.popup = popup;
                popup.feature = feature;
                map.addPopup(popup, true);
				//alert ("select");
            }

Open in new window


I do not get any errors in the console.  It just doesn't display the link.
0
Robert SchuttSoftware EngineerCommented:
The <a href> in the info field needs to be followed by the link text and a closing tag for the link to display, so the JSON file could look something like this:
{
"layers": [
{ "title":"FTMA San Pipe" , "url":"./ftma_sanpipe_3857.geojson" , "style": "layer.styleMap = sanpipe_stylemap;", "info" : "\"Owner: \" + feature.attributes.OWNER + \" <br> \" + \"<a href=\" + feature.attributes.AB_PDF + \">read pdf file</a>\""},
{ "title":"FTMA San MH" , "url":"./ftma_sanmh_3857.geojson" , "style" : "layer.styleMap = manhole_stylemap;", "info" : "\"Mh ID: \" + feature.attributes.STRUCT_ID"}
]
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.