Polymer Google Maps Marker OnClick Function

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>

Answer №1

Make sure to update clickEvents to click-events. Attributes should use dashes for properties written in camelCase (docs).

Additionally, eliminate the curly brackets from the event listener. This syntax was valid in version 0.5 but is no longer supported in version 1.0 (docs).

<google-map-marker click-events="true" on-google-map-marker-click="markerClicked">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What kind of data type should the value property of Material UI TimePicker accept?

While reviewing the documentation, I noticed that it mentions any, but there is no clear indication of what specific data types are supported. The value sent to the onChange function appears to be an object rather than a Date object, and in the TypeScrip ...

How can I efficiently transfer a JavaScript array to a PHP script using the GET method?

My web application is designed with jQuery allowing users to manipulate visual elements. The next step is sending the JavaScript object state to PHP for storage in a database. While I prefer using GET, I am open to solutions that involve POST submission as ...

Issue encountered: Unable to load resource - ajax file upload failed due to net::ERR_SSL_BAD_RECORD_MAC_ALERT error

I've implemented an AJAX form file upload using jQuery. After testing my code across multiple computers and browsers, I've encountered an issue on one Windows 8 machine running Chrome where the upload functionality fails with the following error ...

Establishing a pair of separate static directories within Nest

I am looking to utilize Nest in order to host two static applications. Essentially, I have a folder structure like this: /public /admin /main Within my Nest application, I currently have the following setup: app.useStaticAssets(join(__dirn ...

Ember JS: Master of Controlling

I am working with the following controllers: clusters_controller.js.coffee Portal.DashboardClustersController = Ember.ArrayController.extend dashboard_controller.js.coffee Portal.DashboardController = Ember.ArrayController.extend In my template, I am ...

Exploring the concept of global objects within the expressjs framework

Currently, I am working on building a school management system. One issue I encountered is related to the creation of global objects in my backend when a teacher sends a post request. I am wondering whether multiple teachers accessing the server will res ...

The NextJS homepage and API endpoint are combined on a single page

In my Next.js application, I have multiple pages and I want the component loaded at http://localhost:3000/someEndpoint to be exactly the same as the one loaded at http://localhost:3000/ I have already created an index.js file, but I am unsure how to creat ...

How can you verify the anticipated log output in the midst of a function execution with Jest unit testing?

Below is a demonstration function I have: export async function myHandler( param1: string, param2: string, req: Request, next: NextFunction, ) { const log = req.log.prefix(`[my=prefix]`); let res; If (param1 === 'param1&a ...

Upon concatenation, the screen automatically returns to the beginning of the page

I've set up a page with a list of items, and at the bottom there's a handy "Load more" button that fetches new items to add on top of the existing list: handleLoadProducts = (append = false) => { this.setState({ isLoading: true, ...

Angular input for date is showing wrong value due to timezone problem

My database stores dates in UTC format: this.eventItem.date: "2023-06-21T00:00:00.000Z" The input form field value is showing '2023-06-20' (incorrect day number), which seems to be a timezone issue. I am located in a region with a +3 o ...

Tips for utilizing the simple-peer module within a Node.js environment?

I recently started using Node.js and I'm interested in incorporating the simple-peer module into my application. However, I am struggling to understand how to implement it based on the provided documentation. Are there any resources available that can ...

Combining the `vuex-typex` npm package's `dist/index.js` for optimal performance with Jest testing framework

I initially raised this question as an open issue on GitHub. My experience with Vue.js, Vuex, TypeScript, and vuex-typex has led me to encounter syntax errors during Jest testing. I am relatively new to working with Vue.js, TypeScript, and Jest. It is wo ...

The Cordova Network Information Plugin is experiencing some functionality issues

I successfully developed a Mobile application using Cordova, Onsen UI, and Vue.js. While addressing network connectivity issues, I incorporated the cordova plugin cordova plugin add cordova-plugin-network-information For determining the type of connectio ...

How to retrieve data from a form object sent via cloud function using App Script

Currently, I am in the process of developing a web application that can extract files from a web form and store them in a designated Google Drive folder. After the user submits the form, my goal is to trigger a cloud function using google.script.run while ...

Is it better to execute a function before using useState in React?

I am currently developing a random word generator using Next.js. The state of the three randomly generated words is being managed with the help of useState. However, I encountered an error message from React when I tried to implement it in the following ma ...

Choosing options from an API response in a REACT-JS application

I have a Select Component in my application and I want it to automatically show the selected data once the response is received. import Select from "react-select"; <Select menuPlacement="auto" menuPosition="fixed" ...

The chai expect statement is causing an assertion error that I am currently encountering

Exploring the combination of different data types using a simple addition function. For instance, when adding 1 + 1, we expect to get 2, and when adding 1 + "one", the result should be "1one". Below is the content of my functions.js file: module.exports = ...

The text loader feature in THREE.js is failing to load

My first attempt at coding THREE.js resulted in a black screen when I tried to load the Text loader. Can someone help me resolve this issue? I kept getting the following error even after multiple attempts: three.module.js:38595 GET 404 (Not Found) ...

KnockoutJS's data binding feature is failing to display any content within the table rows

My JavaScript function creates a model and applies it to an HTML document using knockoutJS. In the HTML file, I have two different ways of displaying the same data: 1- A select list (which is working fine) 2- A table (not showing the same data) I need a ...

Verifying that a parameter is sent to a function triggering an event in VueJS

One of the components in my codebase is designed to render buttons based on an array of objects as a prop. When these buttons are clicked, an object with specific values is passed to the event handler. Here's an example of how the object looks: { boxe ...