Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect if click is inside OverlayView
    primarykey
    data
    text
    <p>I want to display a certain Infobox when the user clicks anywhere on the map and a different Infobox when the user clicks inside an OverlayView. </p> <p>I'm adding a listener to the click event for the map object, but this event only provides a latLong param which seems insufficient to tell if an OverlayView was hitted.</p> <pre><code> google.maps.event.addDomListener(map, 'click', function(param) { // if( an OverlayView was clicked) // showInfoboxForOverlayView(); // else // showStandarInfobox(); }); </code></pre> <p>I know I can add a separate listener for the OverlayView object, but when I do this, both events are fired (the one coming from the OverlayView object and the one from the map object). </p> <p>This is how I construct my OverlayView object,</p> <pre><code> var overlay = new google.maps.OverlayView(); overlay.onAdd = function () { var layer = d3.select(this.getPanes().overlayMouseTarget).append("div").attr("class", "SvgOverlay"); var svg = layer.append("svg"); var adminDivisions = svg.append("g").attr("class", "AdminDivisions"); overlay.draw = function () { var markerOverlay = this; var overlayProjection = markerOverlay.getProjection(); // Turn the overlay projection into a d3 projection var googleMapProjection = function (coordinates) { var googleCoordinates = new google.maps.LatLng(coordinates[1] + 0.0005, coordinates[0] - 0.0006); var pixelCoordinates = overlayProjection.fromLatLngToDivPixel(googleCoordinates); return [pixelCoordinates.x + 4000, pixelCoordinates.y + 4000]; } path = d3.geo.path().projection(googleMapProjection); adminDivisions.selectAll("path") .data(geoJson.features) .attr("d", path) // update existing paths .enter().append("svg:path") .attr("d", path);; }; }; </code></pre> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload