Transmitting mouse events from interactive Google Maps overlays

Is there a way to have an overlay on a Google map (such as a circle or polygon) that is clickable, but still allows mouse events to pass through to the underlying map? Currently, it seems like a clickable overlay will always prevent interactions with the map.

For example, I would like both click handlers to be triggered when you click the circle: http://jsfiddle.net/tW9SE/


var circle = new google.maps.Circle({
    map: map,
    center: center,
    radius: 100000,
    clickable: true
});

google.maps.event.addListener(map, "click", function(){
    alert("Map clicked");
});

google.maps.event.addListener(circle, "click", function(){
    alert("Circle clicked");
});

I haven't been able to find a property on the overlay that enables event propagation, other than setting clickable=false which disables event handlers on the overlay itself.

Answer №1

Take control and initiate the click event on your own:

google.maps.event.addListener(circle, "click", function(){
    alert("Circle clicked");
    google.maps.event.trigger(map, 'click', null);
});

For further details, refer to Marcelo's response on how to programmatically trigger clicks on a Google map.

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

vue v-if="canEdit" @click.prevent

I have a Vue component called 'test' with specific template and methods. The goal is to make the div clickable only if helper.isEditable is true, otherwise it should be notClickable or touchable. However, I can only retrieve the value of helper. ...

When incorporating "<" or ">" into a parameter value in Angular Translate and then showcasing it in a textarea with ng-model

In my Angular Translate string, I am using a parameter that can be in the form of <test>. However, when this translate is displayed in a textarea, it shows up as &lt;test&gt; instead of <test>. Is there a way to ensure it appears correc ...

$q.all - successfully resolving some HTTP requests while encountering errors on others

I encountered a coding scenario like this angular.forEach(config.tvshows.shows, function(show) { promises.push($http.get('http://epguides.frecar.no/show/' + show.replace(/\s|\./g, '') + '/next/')); }); re ...

Exploring Keypress events with Dojo's 'on' module

Recently, I've started utilizing Dojo's latest on module for event handling. It has been working well so far, but a new issue has cropped up. Specifically, when using the keypress event, I am unable to retrieve the character value (such as "2" or ...

Searching through a JSON object for nested objects within objects

Currently, I have some data structured as follows: var items = [ { "id" : 1, "title" : "this", "groups" : [ {"id" : 1, "name" : "groupA"}, {"id" : 2, "name" : "groupB"} ] }, { "id" : 2, "title" : "that", ...

Tips for removing ASP.NET MVC controller name from angular route

My ASP.NET MVC login page leads to a different page that is integrated with Angular. After logging in, the URL looks something like this: http://localhost:5083/Home#/home I want to remove the ASP MVC controller name ("Home") from the URL. Is there a ...

Obtaining a fresh access token from a refresh token using the googleapis npm library

I've been searching everywhere for an explanation, but I can't seem to find one. The documentation I've read says that refresh tokens are used to obtain new access tokens, but it doesn't explain the mechanics behind it. Normally, I wou ...

What is the best way to retrieve the value of an input field in React when incorporating Material UI components?

I am working with a few radio input components that have been imported from material Ui react. Each radio input is wrapped in a FormControlLabel component. <FormControlLabel onClick={checkAnswerHandler} value={answer} control={<Radio color=&quo ...

How can I efficiently transfer information between AngularJS modules?

Angular offers the flexibility of creating independent Modules that can be reused in various parts of your application. Imagine having a module dedicated to managing lists, which you want to use across your entire application and populate in different ways ...

Tips for creating a personalized Laravel event that can be tailored to individual users

On each user's screen, there is a grid displaying random products for sale. When another user purchases a product that is visible on other screens, I need it to fade out and load a new product in its place. How can I ensure that the new product broadc ...

Update persistent angular data using grunt automation

Is there a way to dynamically set the remote URL based on my environment in AngularJS? For example: app.constant('fooConst', { urlBase: window.location.origin + '/bar/', urlBaseWebservice: window.location.origin + '/foo/&apos ...

Requesting the user to repeatedly input their birth year until it is less than the current year

Can anyone help me figure out how to display a prompt until the user enters a birth year that is less than the current year? I've tried using a loop in my code, but I'm having trouble getting it right. Any assistance would be greatly appreciated. ...

Using Node.JS and MySQL to optimize data retrieval by combining queries to define variables and select data efficiently

My SQL query that functions perfectly in PHPMyAdmin seems to be causing issues in Node.JS: SET @row_number=0; SELECT * FROM blah blah @row_number blah blah; When attempting to execute both queries in Node.JS using con.query("SET @row_number=0; SELECT * ...

Validating image dimensions with the data-parsley plugin

Is there a way to validate image dimensions with data-parsley? I attempted the code below, but it is not working. data-parsley-dimensions-options='{ "min_width": "100", "max_width": "100", "m ...

Strategies for managing callback responses within Ejs

I'm facing a challenge in my Node.js application where I need to execute an async function within Ejs code and display the result. Here's what I've attempted: <ul> <% setTimeout(function () { %> <% supplies = [1, 2, 3, 4]; %& ...

a guide on monitoring the status of a stripe transaction through a straightforward form and javascript

Currently, I am in the process of setting up Stripe checkout for my website. I have successfully implemented the payment form, but now I need to figure out how to redirect the user to another page after a successful payment. Below is the JavaScript code th ...

Unable to locate the internal/fs module, current solutions are proving ineffective

Every time I try to run my project, I encounter the same issue despite downgrading my node version to 8.4.0 (npm version 5.3.0). I have tried various solutions such as removing the node_modules, running npm cache clean --force, and then npm install, but no ...

Bootstrap Progress Animation Not Scaling Properly

I am encountering an issue with my Bootstrap 2.3 progress bars. They are supposed to show async file reads and be animated by updating their CSS properties using jQuery. However, the problem I'm facing is that the scale seems to be off - when the prog ...

Newbie's guide: Saving information in Ruby on Rails

In my Rails 4 application, I am looking to save questions and answers either in a document or database. Once stored, I want to showcase them on a specific webpage for users to respond. For instance, I envision having a page titled /questions where a quest ...

Exploring the process of sending post data and navigating to a URL using AngularJS

I am working on an application using angularjs 1.6 and Java 8. My goal is to send POST data to another application and navigate to the URL that this external application determines. The purpose of my application is to transmit data about a citizen who wan ...