谷歌地图中的信息窗口是否有模板最佳实践?
我的问题是:我有超过 100 个标记。它们都具有完全相同的结构。我不想在 javascript 中拥有这样的 infowindow 结构:
function showInfowindow(marker, object) {
var html = "<table><tr><td>" + object.name + "</td><td>" + obj.id </td></tr></table>";
infoWindow.setContent(html);
infoWindow.open(map, marker); // map is global defined
}
我知道有一些辅助框架(我认为 jquery 也有一些东西)可以轻松地创建带有附加和前置功能的 html。但我的目的是类似于具有占位符的 HTML 文件。
我在 Symfony2 Bundle VichGeographicalBundle 中发现了类似的东西: https ://github.com/dustin10/VichGeographicalBundle/blob/master/Resources/doc/index.md#popup-info-windows
但是集成到这里不是一个选项(我查看了输出,它生成 javascript 变量,类似于html
上面的变量)
twig
如果有的话,我也对一些解决方案感兴趣。