Thanks Arnd! Will give it a shot.
On Sat, Jun 25, 2011 at 1:26 PM, Arnd Wippermann <[email protected]>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:* [email protected] [mailto: > [email protected]] *Im Auftrag von *Nicholas > Efremov-Kendall > *Gesendet:* Samstag, 25. Juni 2011 18:34 > *An:* [email protected] > *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... >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
