因此,我有a website使用“WP Google Maps”插件。它有点自定义,并将所有在Google Places中注册的Tattoo Parlors的数据提取出来,并将它们显示为我们网站上的标记。从这里,你可以点击“点击这里获取更多信息”,它会显示你店内的谷歌地点评论。尽管如此,该网站还没有设计风格,但对于它的外观有多糟糕表示歉意。如何编辑个人WP Google地图标记(WP Google地图)的数据
我想要做的是给每个客厅标记“发送消息”功能下的“点击此处获取更多信息”文本。现在它只是链接到即将推出的通用页面,并显示在网站上的每个标记上。我想让它链接到他们的Facebook信使链接(例如:https://messenger.com/t/asos)。
我想找出最好的方法来做到这一点 - 我不介意现在自动添加标记发送消息数据,因为我只是想让它首先工作。我已经做了一些研究,但是我找不到任何直接提到这种事情的东西。
下面是标记当前代码:
//assign an infowindow to the marker so that when its clicked it shows the name of the place
google.maps.event.addListener(marker, 'click', (function (marker, x) {
return function() {
infowindow.setContent("<div class='no-scroll'><strong>" + results[x]['place']['name'] + "</strong><br><br>"
+ results[x]['place']['address'] + "<br><br>"
+ "<span style=\"display:table;margin:0 auto; color: #e7711b;\">"
+ results[x]['place']['rating'] + " " + WPacStars.rating_render(results[x]['place']['rating'], 16, 'e7711b')
+ "</span>"
+"<div id='more_info' align='center' style='margin: 0 auto;'>"
+ "<a href='" + WPURLS.siteurl + "/reviews?place_id=" + results[x]['place']['id']
+ "' target='_blank' style='text-align: center; display: block; margin-bottom: 5px; margin-top: 5px;text-decoration: none; font-size: 16px; color: #6495ed'>click here for more info</a>"
+ "<a href=‘https://messenger.com/t/asos' style='text-align: center; display: block; text-decoration: none; font-size: 14px; text-decoration: none; color: #6495ed'>Send Message</a>"
+ "</div></div>");
infowindow.open(MYMAP.map, marker);
}
})(marker, x));
}
}
}
);
}
//}}
};
下面的代码是我的尝试和思考可能会奏效。我不确定if语句是否是最好的解决方法。
//assign an infowindow to the marker so that when its clicked it shows the name of the place
if ['place_id' 1] google.maps.event.addListener(marker, 'click', (function (marker, x) {
return function() {
infowindow.setContent("<div class='no-scroll'><strong>" + results[x]['place']['name'] + "</strong><br><br>"
+ results[x]['place']['address'] + "<br><br>"
+ "<span style=\"display:table;margin:0 auto; color: #e7711b;\">"
+ results[x]['place']['rating'] + " " + WPacStars.rating_render(results[x]['place']['rating'], 16, 'e7711b')
+ "</span>"
+"<div id='more_info' align='center' style='margin: 0 auto;'>"
+ "<a href='" + WPURLS.siteurl + "/reviews?place_id=1"
+ "' target='_blank' style='text-align: center; display: block; margin-bottom: 5px; margin-top: 5px;text-decoration: none; font-size: 16px; color: #6495ed'>click here for more info</a>"
+ "<a href='https://www.facebook.' style='text-align: center; display: block; text-decoration: none; font-size: 14px; text-decoration: none; color: #6495ed'>Send Message</a>"
+ "</div></div>");
infowindow.open(MYMAP.map, marker);
else google.maps.event.addListener(marker, 'click', (function (marker, x) {
return function() {
infowindow.setContent("<div class='no-scroll'><strong>" + results[x]['place']['name'] + "</strong><br><br>"
+ results[x]['place']['address'] + "<br><br>"
+ "<span style=\"display:table;margin:0 auto; color: #e7711b;\">"
+ results[x]['place']['rating'] + " " + WPacStars.rating_render(results[x]['place']['rating'], 16, 'e7711b')
+ "</span>"
+"<div id='more_info' align='center' style='margin: 0 auto;'>"
+ "<a href='" + WPURLS.siteurl + "/reviews?place_id=" + results[x]['place']['id']
+ "' target='_blank' style='text-align: center; display: block; margin-bottom: 5px; margin-top: 5px;text-decoration: none; font-size: 16px; color: #6495ed'>click here for more info</a>"
+ "<a href='/coming-soon' style='text-align: center; display: block; text-decoration: none; font-size: 14px; text-decoration: none; color: #6495ed'>Send Message</a>"
+ "</div></div>");
infowindow.open(MYMAP.map, marker);
}
})(marker, x));
}
}
}
}
//}}
};
任何指导/帮助将是伟大的!我仍然在学习,所以觉得自己很残酷。
谢谢Henris,真的帮了很多!很好的一个伴侣。我希望可以创建一个名为“Messenger”的新邮件类型,然后可以手动输入所有的信使链接 - 然后,我希望可以单独将标记链接到正确的信使链接。但是当我来到它时,我会穿过那座桥! – Richie
当然!如果我的回答对你有帮助,你也可以接受我的回答,这样它可以帮助我和其他人:) – henrisycip
干杯队友,我做到了! :)如果我想创建信使作为自定义帖子类型(这样我可以手动添加信使信息 - 我可以在您提到的变量设置中引用自定义帖子类型吗? – Richie