function checkForMap() { return Y.one(".map-block"); } function mapRendered() { return Y.one(".page-map"); } if (checkForMap()) { var mapSetOptions = setInterval(function(){ console.log("Waiting for map to be rendered (Runs 10 times a second until map is rendered.)"); if (mapRendered()) { Y.all('.page-map').each(function(el) { if (el._node.__map) { el._node.__map.setOptions({ styles: styles, zoom: 14 }); } if (el._node.__marker) { el._node.__marker.setOptions({ icon: { url: "/assets/pin.png", size: new google.maps.Size(96, 122), scaledSize: new google.maps.Size(48, 61), anchor: new google.maps.Point(24, 61) } }); } }); clearInterval(mapSetOptions); } }, 100); }