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?
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.
-
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.
-
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.