Map Listener mapPositionUpdated firing

65 views
Skip to first unread message

Tim Gaul

unread,
Sep 12, 2014, 11:01:55 AM9/12/14
to codenameone...@googlegroups.com
Hi

I'm having different experiences with iOS and Android with regard to this particular listener.  Android (and the simulator) fires the listener once the user's finger has been lifted from the device (i.e. you could drag quite a distance before a position update is experienced).  On iOS the listener fires immediately and continuously, so in the same distance I would have one event fire in Android I have several iOS events firing, picking up the smallest change in position.

What is recommended here? I'm happy with the Android functionality, how could I fire only on a "finger up" event in iOS?

Thanks!

Tim

Shai Almog

unread,
Sep 12, 2014, 1:32:02 PM9/12/14
to codenameone...@googlegroups.com
Hi,
are you referring to the native maps or the MapComponent?

Tim Gaul

unread,
Sep 14, 2014, 4:05:06 AM9/14/14
to codenameone...@googlegroups.com
Hi Shai

This is for the native maps. When defaulting to the MapComponent on the simulator it works as per the Android native map.

Tim

Tim Gaul

unread,
Sep 14, 2014, 5:30:00 AM9/14/14
to codenameone...@googlegroups.com
As per the Google Android API v2 documentation: " onCameraChange(CameraPosition) callback. This callback is guaranteed to be called at the end of every animation but may not be called for intermediate frames."

As per Google Maps SDK for iOS: "mapView:didChangeCameraPosition: is called repeatedly during a gesture or animation, always after a call to mapView:willMove:. It is passed the intermediate camera position."

As such it seems the Android callback fires after the animation and the iOS callback fires intermediately, which is what I am experiencing.

I've update the Google Maps library to rather use: "mapView:idleAtCameraPosition: is invoked once the camera position on GMSMapView becomes idle, and specifies the camera positon in question. At this point, all animations and gestures have stopped."

Which is a much closer fit to the onCameraChange(CameraPosition) callback, and provides a more consistent behaviour over devices.

Hopefully, this explains it!



On Friday, September 12, 2014 7:32:02 PM UTC+2, Shai Almog wrote:

Shai Almog

unread,
Sep 14, 2014, 9:42:45 AM9/14/14
to codenameone...@googlegroups.com
This should only fire on the pointer release event or on a zoom in/zoom out button press for that case.

Tim Gaul

unread,
Oct 2, 2014, 4:37:16 AM10/2/14
to codenameone...@googlegroups.com
Hi Shai

iOS mapView:didChangeCameraPosition fires repeatedly when I move position ending up with many, many events. The Android onCameraChange(CameraPosition) callback fires on pointer release (as does iOS mapView:idleAtCameraPosition) resulting in a single event.

This change sorted out my issue.

Regards

Tim

Oscar Corredor

unread,
Oct 2, 2014, 12:37:27 PM10/2/14
to codenameone...@googlegroups.com
Hey guys, 

regarding this issue, has the NativeMaps cn1Lib on the SVN been updated or at least the code so I can generate it?  


Thanks. 

Shai Almog

unread,
Oct 2, 2014, 1:20:18 PM10/2/14
to codenameone...@googlegroups.com
Hi,
I'm hesitant about changing the native maps event callbacks which might break some existing code but I understand this works for you?

The simulator map should be solved by a Codename One update since its in the core.
Reply all
Reply to author
Forward
0 new messages