Google Maps Extension: Drawing rectangle breaks MapClick event

Answered
0
0

Official rectangle documentation: https://developers.google.com/maps/documentation/javascript/examples/rectangle-simple

https://developers.google.com/maps/documentation/javascript/shapes#rectangles

 

Consider this Javascript function that works with a WiseJ GoogleMap:

 

function drawMapRectangle(googleMap, northlat, southlat, eastlon, westlon) {
var map = googleMap.map;

var rectangle = new google.maps.Rectangle({
strokeColor: ‘#FF0000’,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: ‘#00FF66’,
fillOpacity: 0.05,
map: map,
bounds: {
north: northlat,
south: southlat,
east: eastlon,
west: westlon
}
});
}

 

 

When calling it from WiseJ like this:

Application.Call(“window.drawMapRectangle”, mobjGoogleMap, curCity.northlat, curCity.southlat, curCity.eastlon, curCity.westlon); // call javascript

 

It does draw a rectangle.  But right-clicking inside of it does not register the MapClick event in WiseJ

 

// mobjGoogleMap_MapClick: Handle click event of Google Map
private void mobjGoogleMap_MapClick(object sender, MapMouseEventArgs e)
{
// save location
rightClickLocation = e.Location; // update last click location

}

 

Right-clicks outside the drawn rectangle will still trigger the event.

 

 

  • You must to post comments
Good Answer
0
0

The answer is to set  clickable: false  in the rectangle (undocumented), thus the rectangle with a higher zOrder than the map will miss the click, and it will go through to the map.

  • You must to post comments
0
0

Hi Andrew,

Could you please attach a small runnable sample excluding the API key so we can test it?

Thanks,

Levie

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.