Link to home
Start Free TrialLog in
Avatar of GreyHippo
GreyHippo

asked on

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 + ">"
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

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&
Avatar of GreyHippo
GreyHippo

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial