benekastah
benekastah

Reputation: 5711

Manually triggering mouse event doesn't give me latLng

I am triggering a mouse event on the map from an absolutely positioned dom element that is over the map (this element follows my mouse). I want the mouseup element to trigger on the map as if the mouseup had been performed on the map directly. Most importantly, I want the latLng coordinates for the position over which the mouse button was released. Here is the relevant portion of my code (regarding the element that follows the mouse).

var mouseup = google.maps.event.addListenerOnce(_map, 'mouseup', function(event) {
  placeMarker(event.latLng);
  addPinClone.remove();
  return bean.remove(window, "mousemove.window__temp__");
});

var addPinClone = $("<div class='map-add-pin'>").css({
  opacity: .4,
  position: "absolute"
}).mouseup(function(evt) {
  return google.maps.event.trigger(_map, "mouseup", evt);
}).appendTo("#map");

If I click the map directly, I get event.latLng in my mouseup event. When I trigger the event from the floating element, I do not.

I tried to omit the mouseup function on addPinClone altogether, hoping the event would bubble up to the map properly, but that didn't work either.

How do I get the latLng from here?

Upvotes: 0

Views: 460

Answers (1)

duncan
duncan

Reputation: 31912

mouseup is not a documented event on the Map class (it is on Marker, Polygon, Rectangle and Circle, i.e. things you might drag around on the map). So I'd guess it's impossible for you to trigger that event. Although interesting that anything happens at all for a normal click on the map.

Upvotes: 1

Related Questions