registerOnRenderMapScale method
void
registerOnRenderMapScale(
- RenderMapScaleCallback? scaleCallback, {
- bool onlyOnChange = false,
Registers for map scale rendering callbacks.
Requires MapViewPreferences.showMapScale to be true. Adjust scale
positioning using MapViewPreferences.mapScalePosition.
The callback is invoked twice per rendered frame, and the scale only
changes when the zoom level does, so most of those invocations repeat the
previous values. Pass onlyOnChange to receive the changes alone.
Parameters
scaleCallback: (RenderMapScaleCallback?) Receives scale width, value, and units. Passnullto unregister.onlyOnChange: (bool) When true, the callback is invoked only when at least one of the three values differs from the last one delivered. The first values after registering always arrive. Defaults to false, which invokes the callback for every rendered frame.
Implementation
void registerOnRenderMapScale(
RenderMapScaleCallback? scaleCallback, {
bool onlyOnChange = false,
}) {
_renderMapScaleCallback = scaleCallback;
// Set before the event is unblocked so the first delivered frame is already
// governed, and on every call so registering again starts from a clean
// comparison rather than waiting for the next scale change.
objectMethod(
pointerId,
'MapView',
'setRenderMapScaleOnlyOnChange',
args: onlyOnChange,
);
GemKitPlatform.instance.filterEvent(
pointerId,
'renderMapScale',
scaleCallback == null,
);
}