![](/img/trans.png)
[英]Polymer: Applying animations to dom elements in dom-repeat template
[英]Access elements in Polymer dom-repeat template
我正在嘗試訪問在dom-repeat模板中創建的元素,以便可以以編程方式對其進行修改。
<google-map id="map">
<template is="dom-repeat" id="markers" items="{{items}}">
<google-map-marker latitude="item.latitude" longitude="item.longitude">
</google-map-marker>
</template>
</google-map>
我可以做些什么來在模板中獲取一組google-map-markers? 我在文檔的任何地方都找不到解決此問題的方法。
我最終以編程方式創建和插入標記。
HTML:
<google-map id="map">
</google-map>
JavaScript:
for (var i=0; i<this.items.length; i++) {
var marker = document.createElement('google-map-marker');
marker.latitude = this.items[i].latitude;
marker.longitude = this.items[i].longitude;
//any additional operations that are needed
Polymer.dom(this.$.map).appendChild(marker);
}
根據文檔: https : //elements.polymer-project.org/elements/google-map
markers屬性會返回地圖上的只讀數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.