move method
bool
move(
- LatLng center,
- double zoom, {
- bool hasGesture = false,
- bool callOnMoveSink = true,
- required MapEventSource source,
- String? id,
Implementation
bool move(LatLng center, double zoom,
{bool hasGesture = false,
bool callOnMoveSink = true,
required MapEventSource source,
String? id}) {
zoom = fitZoomToBounds(zoom);
final mapMoved = center != _lastCenter || zoom != _zoom;
if (_lastCenter != null && (!mapMoved || !bounds.isValid)) {
return false;
}
if (options.isOutOfBounds(center)) {
if (!options.slideOnBoundaries) {
return false;
}
center = options.containPoint(center, _lastCenter ?? center);
}
// Try and fit the corners of the map inside the visible area.
// If it's still outside (so response is null), don't perform a move.
if (options.maxBounds != null) {
final adjustedCenter =
adjustCenterIfOutsideMaxBounds(center, zoom, options.maxBounds!);
if (adjustedCenter == null) {
return false;
} else {
center = adjustedCenter;
}
}
_handleMoveEmit(center, zoom, hasGesture, source, id);
_zoom = zoom;
_lastCenter = center;
_lastPixelBounds = getPixelBounds(_zoom);
_lastBounds = _calculateBounds();
_pixelOrigin = getNewPixelOrigin(center);
if (callOnMoveSink) {
_onMoveSink.add(null);
}
if (options.onPositionChanged != null) {
final mapPosition = MapPosition(
center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture);
options.onPositionChanged!(mapPosition, hasGesture);
}
return true;
}