Tweet按钮和infoWindow [英] Tweet button and infoWindow

查看:122
本文介绍了Tweet按钮和infoWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Tweet按钮集成到Google Maps v3 infoWindow(infoBox)中,但我没有成功。当然,我使用的脚本在一个简单的页面上工作。我在模板文件中设置了twitter的js,添加了gmaps javascript文件中html变量的锚点:$ b​​ $ b ...
Tweet
...



如果我将鼠标悬停在锚链接上,并且没有看到Tweet图片按钮,现在可以看到的只是Tweet文本。如果我点击这个按钮,Twitter网站将加载但不分享任何东西。



使用Facebook Like按钮时,我必须实现一行代码,以便domready事件运行。



如何做Twitter?

解决方案

同样的问题,但越来越接近解决它。



我猜你正在使用标准 Twitter例子您可以在其中添加< a> 标签:

 < a href =https://twitter.com/shareclass =twitter-share-button
data-郎= EN >资料Tweet< / A>

然后需要加载它们的JavaScript:

 < script>!function(d,s,id){var js,fjs = d.getElementsByTagName(s)[0]; 
if(!d.getElementById(id)){js = d.createElement(s); js.id = id;
js.src =// platform.twitter.com/widgets.js;
fjs.parentNode.insertBefore(js,fjs);
}}(文档,script,twitter-wjs);< / script>

所以问题很可能是infoWindow没有附加到 DOM Google Maps V3 API InfoWindow Class 有一个事件domready。



因此,如果您像我一样使用 jQuery ,您需要执行以下操作:

  google.maps.event.addListener(bubble,'domready',function(event){
!function(d,s,id ){var js,fjs = d.getElementsByTagName(s)[0];
if(!d.getElementById(id)){js = d.createElement(s); js.id = id;
js.src =// platform.twitter.com/widgets.js;
fjs.parentNode.insertBefore(js,fjs);}}(document,script,twitter-wjs);
});

记住我还没有这个工作:)



让我们把这个傻瓜分类出来!


I want to integrate Tweet button into a Google Maps v3 infoWindow (infoBox), with I have no success. Of course the script I use works on a simple page. I set up the twitter's js in my template file, added anchor to the html variable in the gmaps javascript file: ... Tweet ...

What now can be see is only the "Tweet" text if I hover over the anchor link, and no Tweet grapic button is visible. If I click on this button, Twitter site loads but shares nothing.

With Facebook Like button I had to implement a line of code, whet the "domready" event runs.

How to do it Twitter?

解决方案

I'm having the same problem but am getting closer to solving it.

I'm guessing you're using the standard Twitter examples where you add an <a> tag like:

<a href="https://twitter.com/share" class="twitter-share-button" 
data-lang="en">Tweet</a>

And then need to get their JavaScript to load:

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}}(document,"script","twitter-wjs");</script>

So the problem is likely that the infoWindow isn't getting attached to the DOM.

The Google Maps V3 API InfoWindow Class has an Event "domready".

So if you're using jQuery like I am then you need to do something like:

google.maps.event.addListener(bubble, 'domready', function(event) {
        !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
        if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
        js.src="//platform.twitter.com/widgets.js";
        fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
});

Bearing in mind that I haven't got this to work yet :)

Let's sort this sucker out!

这篇关于Tweet按钮和infoWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆