Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

RegionChanged event fires 4 times initially

I am trying to utilize the regionChanged event with a mapView to continually redraw pins based on where the users moves or zooms the map to. This all works fine, however, I notice that on the initial load of the mapView, this event fires 4 times.

To see this in action, add the following code into the map_view.js file within the KitchecnSink

mapview.addEventListener('regionChanged', function()
{
    alert("regionChanged");
})

Bug?

— asked September 12th 2010 by Bart Lewis
  • mapview
0 Comments

3 Answers

  • I'm noticing this behavior, iPhone SDK 4.2, Ti SDK 1.5.1. Not sure if it's related, but for some reason adding an event listener for regionChanged also seems to override a location set on the map view before it's opened. Kind of inconvenient.

    — answered January 8th 2011 by Ken-ichi Ueda
    permalink
    0 Comments
  • This is still happening in the 1.7 RC for both the MapView "regionChanged" event and the Geolocation "location" event. I ended up adding logic to not update the map on the first three event calls and then push the annotations on the calls from the 4th on. I also found that when the app resumes from the background t also triggers 4 updates, in this case I'm resetting the counters on resume.

    — answered May 22nd 2011 by Joe Chavez
    permalink
    0 Comments
  • Just started working more with MapViews, yeah this is lame. Having to do a work around because of when the user moves with the view … I have to update the map with updated Annotations.

    — answered October 19th 2011 by Brian Wells
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.