I am struggling to trigger a click event for a google maps marker while utilizing the Polymer web component. After reviewing this question on Stack Overflow, I have noticed a minor difference in my code that may be causing issues. My implementation involves using a template with "dom-repeat" inside my marker to enable searching using the places API. Below is the code snippet for the
<map-element></map-element>
. How can I ensure that markerClicked
gets fired properly? The on-google-map-marker-click
event does not seem to be triggering:
<dom-module id="map-element">
<style>
google-map {
height: 200px;
width: 100%;
}
</style>
<template>
<iron-icon icon="icons:search"></iron-icon>
<input is="iron-input" bind-value="{{bindValue}}" value=" {{value::input}}">
<google-map-search map="[[map]]" query="[[bindValue]]" results="{{results}}"></google-map-search>
<google-map map="{{map}}" latitude="37.77493" disableZoom="true" longitude="-122.41942" fit-to-markers>
<template is="dom-repeat" items="{{results}}" as="marker">
<google-map-marker latitude="{{marker.latitude}}" longitude="{{marker.longitude}}" clickEvents="true" on-google-map-marker-click="{{markerClicked}}">
<h2>{{marker.name}}</h2>
<span>{{marker.formatted_address}}</span>
</google-map-marker>
</template>
</google-map>
</template>
<script>
Polymer({
is: "map-element",
markerClicked: function(e, detail, sender) {
console.log('google_map_marker_click');
}
});
</script>
</dom-module>