[OpenLayers-Users] passing html string to popup

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Sat Jun 25 12:33:31 EDT 2011


Hi all,

I'm currently creating popups and populating their html content with the
following code


function onFeatureSelect(evt)
{selectedFeature = evt.feature;
popup = new OpenLayers.Popup.FramedCloud(
"chicken",
evt.feature.geometry.getBounds().getCenterLonLat(),
null,
"<div style='font-size:.8em'>User Name: " +evt.feature.id + "</div>",

null, true, onPopupClose);evt.feature.popup = popup; map.addPopup(popup);}

rather than pull out the attributes myself, I'd like to pass in a preformed
html string via a variable, but I'm not sure how to do this, and I currently
lack a sufficient knowledge of jscript syntax to research this. I can form
an html string via this function but I'm not sure how to pass it back to the
popup function above...

function popupHTML(tweet) {
var retval = '';
retval += '<div class="tweet_info">';
retval += '<img alt="' + tweet.from_user_id + '" src="' +
tweet.profile_image_url + '" class="tweet_profile"/>';
retval += '<h3>' + tweet.from_user + '</h3>';
retval += '<p>' + tweet.text + '</p>';
retval += '<p>Source: <a href="' + tweet.source + '"/>' +
tweet.source + '</a></p>';
retval += '</div>';
return retval;
}

thanks again in advance...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110625/03fc18d9/attachment.html


More information about the Users mailing list