Facebook Comments Stream in Google Maps Infowindow

隐身守侯 提交于 2019-12-11 03:29:35

问题


I’m currently working on a Google Maps project showing places of interest in my local town. My plan was to use multiple markers on the map to identify different places which when clicked on would open an InfoWindow listing more details about the place.... I also thought it would be good to allow visitors to leave comments and experiences using the Facebook Comments Plugin within the InfoWindow.

However, on further research and reading a couple of other peoples efforts into trying to get Facebook Comments into InfoWindows it doesn’t seem possible... the closet I’ve seen is a chap who managed to get the SAME comments stream appearing in every InfoWindow no matter which marker / point on map was selected.... which isn’t what I want! His conclusion was to build your own comments stream in PHP.

Here's the link to the above article which has a link to the map at work; https://groups.google.com/forum/#!msg/google-maps-js-api-v3/4wvBdVxPHJ0/vxuYP93N-lgJ

I’m pretty new to Facebook development but certainly don’t mind climbing the learning curve to achieve what I want, but thought it wise to check with the experts here at stackoverflow in case what I am trying to achieve is a non-starter!

Any suggestions, advice and pointers would be gratefully received.


回答1:


I recently managed to do it. The trick is to

  • insert the content of your infowindow on the end of the page in a hidden div.
  • parse this div with FB.XFBML.parse
  • get the innerHTML of your div
  • call infowindow.setContent() with the innerHTML you got before

If you want different comments in every infowindow you must have a different url for every infowindow's comment plugin: like http://localhost?infowindow=content1 and http://localhost?infowindow=content2 for another.

Hope that helped!



来源:https://stackoverflow.com/questions/10701950/facebook-comments-stream-in-google-maps-infowindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!