我triyng使用latlng
爲google-map-directions
聚合物元素。如果我只是放入一個字符串,如Austin
它可以工作,並有方向。但如果我嘗試new google.maps.LatLng(29.520332, -98.431211)
沒有方向。要清楚,以太沒有錯誤。聚合物谷歌地圖方向 - 使用latlng結束地址
在模板我輸出{{endingAddress}}
,它成功輸出字符串(...., ....)
,所以數據綁定是正確的和工作。
有什麼建議嗎?
<div id="map-container">
<google-map latitude="29.520332" longitude="-98.431211"
api-key='AIzaXjfkwM'
fit-to-markers>
<google-map-marker latitude="29.520332" longitude="-98.431211"
title="wedding location"></google-map-marker>
</google-map>
<google-map-directions
api-key='AICpwM'
start-address="Austin"
end-address$="{{endingAddress}}"></google-map-directions>
</div>
</div>
</template>
<script>
Polymer({
is: 'map-wedding',
properties: {
endingAddress: {
type: Object
}
},
attached: function() {
var gMap = document.querySelector('google-map');
gMap.addEventListener('api-load', function(e) {
document.querySelector('google-map-directions').map = this.map;
this.endingAddress = new google.maps.LatLng(29.520332, -98.431211);
}.bind(this));
}
})