[OpenLayers-Users] passing html string to popup
Nicholas Efremov-Kendall
n.e.kendall at gmail.com
Sat Jun 25 14:41:41 EDT 2011
Thanks Arnd!
Will give it a shot.
On Sat, Jun 25, 2011 at 1:26 PM, Arnd Wippermann <arnd.wippermann at web.de>wrote:
> **
> Hi,
>
> if you know the argument "tweet" from your evt.feature, then the below code
> should work:
>
> function onFeatureSelect(evt)
> {
> selectedFeature = evt.feature;
> tweet = ...;
> popup = new OpenLayers.Popup.FramedCloud(
> "chicken",
> evt.feature.geometry.getBounds().getCenterLonLat(),
> null,
> popupHTML(tweet), //returns the html string
>
>
> null, true, onPopupClose);
> evt.feature.popup = popup;
> map.addPopup(popup);
> }
> Arnd
> ------------------------------
> *Von:* openlayers-users-bounces at lists.osgeo.org [mailto:
> openlayers-users-bounces at lists.osgeo.org] *Im Auftrag von *Nicholas
> Efremov-Kendall
> *Gesendet:* Samstag, 25. Juni 2011 18:34
> *An:* users at openlayers.org
> *Betreff:* [OpenLayers-Users] passing html string to popup
>
> 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/85c35fc6/attachment.html
More information about the Users
mailing list