3

I am looking for a click event for a google maps marker when using the Polymer web component. I have looked at this SO question but I have a slight difference in my code that might be screwing things up. I am using a template is="dom-repeat" inside my marker so that I can search using the places API. Here is my code for the <map-element></map-element>. Question is how can I get markerClicked to fire? on-google-map-marker-click doesn't seem to be working:

<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>
Community
  • 1
  • 1

1 Answers1

8

ChangeclickEvents to click-events. Properties with camelCase translate to attributes with dashes (docs).

Also, remove the curly brackets from the event listener. That syntax was used in 0.5, but no longer in 1.0 (docs).

<google-map-marker click-events="true" on-google-map-marker-click="markerClicked">
Maria
  • 5,574
  • 1
  • 29
  • 39