Google Maps Event - Addlistener

Asked

Viewed 447 times

0

Hello, I wonder if anyone has any notion of how to return a GLOBAL event from anything done on the map to be interpreted with CASE! Below how I use them today.

google.maps.Event.addListener(map, "click", Function() {

In this case, I didn’t want to define the CLICK example, but analyze it later, something like:

google.maps.Event.addListener(map, Function(Event) {

Then later analyze in CASE which event came to deal with CASE and BREAK because I use 3 events on the map, and when the 3 run simultaneously ends up getting 3 information on the map and this overloading when it gathers a lot of information.

if anyone knows any method because I’ve tried everything and I haven’t been able to.

Thank you from now on.

  • I don’t know this control of multiple events, I believe you can only control one at a time. It was not very clear what would be this "lots of information" that you spoke but being a bookmark or the text of a infowindow you could clean and redesign whenever one of the events is called (it’s ugly but it works :P)

1 answer

0


After I commented I was thinking of a better solution.. you can use the idea of cleaning/redesigning but using a timeout to decrease the number of redesign.

var EventoDisparado = false;

$(document).ready(function() {
  //código
  window.setTimeout("MuitasInformacoes", 1000);
});

function initMap(){
  //código
  google.maps.event.addListener(map, "evt_01", function(event) { 
    EventoDisparado = true;
  }); 
  google.maps.event.addListener(map, "evt_02", function(event) { 
    EventoDisparado = true;
  });
  google.maps.event.addListener(map, "evt_03", function(event) { 
    EventoDisparado = true;
  });
}

function MuitasInformacoes() {
  if (EventoDisparado) {
    //TODO: add as info
  }
  EventoDisparado = false;
}
  • I took your idea and made some changes and it worked perfectly. The only thing I did of change was when firing an event it changes this value, and the functions that do add marker / polylines it checks this information and aborts if necessary! Also I did not use delay because I just want to load the information once.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.