You have markers="{{locations}}" , which is a pure JSON response from the polymer-jsonp . I had to convert the data and parse the lat / lng first:
var markers = []; markers.push({ lat: parseFloat(entry.gsx$lat.$t), lng: parseFloat(entry.gsx$lng.$t), name: entry.gsx$name.$t }); this.markers = markers;
What I turned to is to reuse the existing google-map Polymer element: http://jsbin.com/wowuledo/6/edit
The important bit is that when you change the this.markers array, this.markers is markersChanged , which in turn calls your addMarkers (which I changed):
markersChanged: function() { this.addMarkers(); }, addMarkers: function() { this.markers.forEach(function(marker) { var marker = new google.maps.Marker({ map: this.map, position: new google.maps.LatLng(marker.lat, marker.lng), title: marker.name }); }.bind(this)); }
If you have to create an additional element to add your own properties / methods, why not inherit from google-maps ?
<polymer-element name="google-map-with-markers" extends="google-map" attributes="markers">
This way you get all the functionality from google-maps , but you can bind the data to the published markers property:
<google-map-with-markers latitude="45.526158" longitude="-122.679394" zoom="14" markers="{{markers}}"></google-map-with-markers>
Try: http://jsbin.com/renuyifu/1/edit
source share