我有一个谷歌地图元素,并渲染一些谷歌地图标记,如下面的代码
<google-map>
<template id="markerList"
is="dom-repeat" items="{{response}}"
initial-count="10"
filter="{{computeFilterMap(searchString)}}">
<google-map-marker
latitude="{{item.lat}}" longitude="{{item.lon}}"
title="{{item.location}}"
animation="DROP"
icon="{{computeOnOffIcon(item.onOff)}}"
on-google-map-marker-open="markerClick">
<h4>{{item.location}}</h4>
<div><!-- other info --></div>
</google-map-marker>
</template>
</google-map>
另外,我有一个搜索过滤功能。
computeFilterMap = function(string){
if (!string) {
// set filter to null to disable filtering
return null;
} else {
string = string.toLowerCase();
return function(movil) {
// Location
var location = movil.location.toLowerCase();
// true or false
var motor = movil.onOff? "On" : "Off";
return (location.indexOf(string) != -1 ||
motor.indexOf(string) != -1 ||
pat.indexOf(string) != -1);
};
}
}
一些数据:
[
{
"location": "antofagasta",
"lat": -23.6283541,
"lon": -70.474539,
"motor": true
},
{
"location": "Calama",
"lat": -22.4612687,
"lon": -68.9584051,
"motor": false
},
{
"location": "Las Vegas",
"lat": 36.1246738,
"lon": -115.455193,
"motor": false
}
]
问题: 过滤器功能工作正常,它在正确的位置(lat,lon)显示标记,但google-map-marker的infowindows无法正确呈现,它显示列表的第一个元素的信息。
我试试: