Skip to content

Commit c0de8ad

Browse files
committed
ctrl key toggle
1 parent 6c1aa3e commit c0de8ad

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

example/lib/styled_map_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class _StyledMapPageState extends State<StyledMapPage> {
3939
initCenter: const Geographic(lon: 9.17, lat: 47.68),
4040
initZoom: 2,
4141
initStyle: _style.uri,
42-
gestures: const MapGestures.none()
4342
),
4443
children: const [
4544
MapScalebar(),

maplibre/lib/src/map_state.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:ui';
22

33
import 'package:flutter/gestures.dart';
44
import 'package:flutter/material.dart';
5+
import 'package:flutter/services.dart';
56
import 'package:maplibre/maplibre.dart';
67
import 'package:maplibre/src/inherited_model.dart';
78
import 'package:maplibre/src/layer/layer_manager.dart';
@@ -185,7 +186,9 @@ abstract class MapLibreMapState extends State<MapLibreMap>
185186
_secondToLastScaleUpdateDetails = _lastScaleUpdateDetails;
186187
_lastScaleUpdateDetails = details;
187188

188-
if ((pointerDownEvent.buttons & kSecondaryMouseButton) != 0) {
189+
final ctrlPressed = HardwareKeyboard.instance.isControlPressed;
190+
final buttons = pointerDownEvent.buttons;
191+
if ((buttons & kSecondaryMouseButton) != 0 || ctrlPressed) {
189192
// secondary button (right)
190193
final lastPointerOffset = lastEvent?.focalPoint ?? startEvent.focalPoint;
191194
final delta = details.focalPoint - lastPointerOffset;
@@ -195,7 +198,7 @@ abstract class MapLibreMapState extends State<MapLibreMap>
195198
pitch: camera.pitch - delta.dy * 0.5, // sensitivity
196199
zoom: camera.zoom, // TODO adjust for globe projection
197200
);
198-
} else if ((pointerDownEvent.buttons & kPrimaryMouseButton) != 0) {
201+
} else if ((buttons & kPrimaryMouseButton) != 0) {
199202
// primary button (left)
200203

201204
// zoom

0 commit comments

Comments
 (0)